Bug 235445

Summary: Build failure with g++ 12: std::exchange undefined
Product: WebKit Reporter: Mike Gorse <mgorse>
Component: WebKitGTKAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, bugs-noreply, cdumez, cmarcelo, ews-watchlist, keith_miller, mark.lam, mcatanzaro, mgorse, msaboff, saam, tzagallo
Priority: P2    
Version: WebKit Nightly Build   
Hardware: All   
OS: Linux   
See Also: https://bugs.webkit.org/show_bug.cgi?id=235458
Attachments:
Description Flags
Patch.
none
Patch. none

Description Mike Gorse 2022-01-21 09:29:15 PST
We are trying to get openSUSE ready for the upcoming gcc 12 release. Building with the development version gives me a few errors like this:
/home/abuild/rpmbuild/BUILD/webkitgtk-2.34.3/Source/WTF/wtf/CompletionHandler.h:67:21: error: 'exchange' is not a member of 'std'
67 |         return std::exchange(m_function, nullptr)(std::forward<In>(in)...);

I'm not sure why this fails on 12 but not 11, but including <utility> fixes the build for me.
Comment 1 Mike Gorse 2022-01-21 09:32:41 PST
Created attachment 449667 [details]
Patch.
Comment 2 Michael Catanzaro 2022-01-21 09:33:03 PST
(In reply to Mike Gorse from comment #0)
> I'm not sure why this fails on 12 but not 11, but including <utility> fixes
> the build for me.

Some other libstdc++ header must have included it from somewhere. It's normal for libstdc++ to remove headers when not required by the standard. When that happens, if we are missing the header where it's needed, then we get a build failure. This is just part of normal uplift of a new compiler version.
Comment 3 Michael Catanzaro 2022-01-21 09:33:52 PST
Comment on attachment 449667 [details]
Patch.

View in context: https://bugs.webkit.org/attachment.cgi?id=449667&action=review

> Source/WTF/wtf/CompletionHandler.h:30
>  #include <wtf/MainThread.h>
> +#include <utility>

I'm just going to ask that you alphabetize. The style bot is about to yell at you for that.
Comment 4 Mike Gorse 2022-01-21 11:36:03 PST
Thanks; I'll submit a new patch.
I also have a change for 2.34.4 to include <string> in IntegerToStringConversion.h, but it seems not to be needed in the development branch, so I didn't include it.
Comment 5 Mike Gorse 2022-01-21 12:01:15 PST
Created attachment 449680 [details]
Patch.
Comment 6 Michael Catanzaro 2022-01-21 12:52:00 PST
(In reply to Mike Gorse from comment #4)
> Thanks; I'll submit a new patch.
> I also have a change for 2.34.4 to include <string> in
> IntegerToStringConversion.h, but it seems not to be needed in the
> development branch, so I didn't include it.

You can attach it separately to this bug, and I'll ask for it to be added to the stable tree.
Comment 7 EWS 2022-01-21 13:48:48 PST
Committed r288379 (246276@main): <https://commits.webkit.org/246276@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 449680 [details].