Bug 234412

Summary: REGRESSION(r287138) [GLIB] Build failure with GCC 8 and 9 in std::array to Span conversion
Product: WebKit Reporter: Lauro Moura <lmoura>
Component: WebKit Misc.Assignee: Carlos Alberto Lopez Perez <clopez>
Severity: Normal CC: aboxhall, andresg_22, apinheiro, bugs-noreply, cfleizach, clopez, darin, dmazzoni, ews-watchlist, jcraig, jdiggs, rbuis, samuel_white, sam, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=234350
Description Flags
Example that fails with GCC-9 and builds with GCC-10
Patch ews-feeder: commit-queue-

Description Lauro Moura 2021-12-16 17:29:29 PST
Created attachment 447403 [details]
Example that fails with GCC-9 and builds with GCC-10

Attached minimal example built with snippets from Span.h and its usage in AccessibilityRenderObject.cpp (Link to compiler explorer: https://godbolt.org/z/qxTK1qdda)

Minimum GCC working version: gcc 10
Minimum CLANG working version: clang 7

List of C++ features supported by GCC: https://gcc.gnu.org/projects/cxx-status.html
List of C++ GCC 10 changes: https://gcc.gnu.org/gcc-10/changes.html#cxx

Link to build job of the first failure: https://build.webkit.org/#/builders/46/builds/9542

../../Source/WebCore/accessibility/AccessibilityRenderObject.cpp: In member function ‘virtual bool WebCore::AccessibilityRenderObject::inheritsPresentationalRole() const’:
../../Source/WebCore/accessibility/AccessibilityRenderObject.cpp:3222:22: error: no match for ‘operator=’ (operand types are ‘WTF::Span<const WTF::LazyNeverDestroyed<const WebCore::HTMLQualifiedName>* const>’ and ‘const std::array<WTF::LazyNeverDestroyed<const WebCore::HTMLQualifiedName>*, 3>’)
         parentTags = listItemParents;
In file included from WTF/Headers/wtf/Vector.h:37,
                 from WTF/Headers/wtf/Threading.h:48,
                 from WTF/Headers/wtf/WeakPtr.h:31,
                 from WTF/Headers/wtf/text/TextStream.h:33,
                 from WTF/Headers/wtf/ObjectIdentifier.h:32,
                 from ../../Source/WebCore/page/FrameIdentifier.h:28,
                 from ../../Source/WebCore/loader/FrameLoaderClient.h:32,
                 from ../../Source/WebCore/accessibility/AccessibilityObjectInterface.h:30,
                 from ../../Source/WebCore/accessibility/AccessibilityObject.h:32,
                 from ../../Source/WebCore/accessibility/AccessibilityMockObject.h:28,
                 from ../../Source/WebCore/accessibility/AccessibilityMockObject.cpp:27,
                 from WebCore/DerivedSources/unified-sources/UnifiedSource-aba958d6-3.cpp:1:
WTF/Headers/wtf/Span.h:289:21: note: candidate: ‘constexpr WTF::Span<_Tp, 18446744073709551615>& WTF::Span<_Tp, 18446744073709551615>::operator=(const WTF::Span<_Tp, 18446744073709551615>&) [with _Tp = const WTF::LazyNeverDestroyed<const WebCore::HTMLQualifiedName>* const]’
     constexpr Span& operator=(const Span&) noexcept = default;
WTF/Headers/wtf/Span.h:289:21: note:   no known conversion for argument 1 from ‘const std::array<WTF::LazyNeverDestroyed<const WebCore::HTMLQualifiedName>*, 3>’ to ‘const WTF::Span<const WTF::LazyNeverDestroyed<const WebCore::HTMLQualifiedName>* const>&’
In file included from WebCore/DerivedSources/unified-sources/UnifiedSource-aba958d6-3.cpp:5:
Comment 1 Carlos Alberto Lopez Perez 2021-12-16 18:32:17 PST
GCC 8 also fails with the same error than GCC 9 (GCC 8 is still supported)

The example builds fine with "-std=c++17" on GCC-10 but not on 9 and 10.

And according to https://gcc.gnu.org/projects/cxx-status.html GCC 8 already has full support for C++-17

So maybe this is a bug on the compiler, hard to tell.
Comment 2 Darin Adler 2021-12-16 18:35:22 PST
Would be nice to find a workaround too.
Comment 3 Carlos Alberto Lopez Perez 2021-12-16 18:40:26 PST
This info is maybe useful, Clang 6 fails with the same error (or very similar).

$ clang++-6.0 -std=c++17  span_gcc.cpp
span_gcc.cpp:211:10: error: no viable overloaded '='
    span = arr;
    ~~~~ ^ ~~~
span_gcc.cpp:150:21: note: candidate function not viable: no known conversion from 'const std::array<int *, 3>' to 'const Span<const int *const, 18446744073709551615>' for 1st argument
    constexpr Span& operator=(const Span&) noexcept = default;
1 error generated.

And clang++-7 builds it fine
Comment 4 Carlos Alberto Lopez Perez 2021-12-16 19:42:17 PST
Created attachment 447413 [details]
Comment 5 EWS 2021-12-16 22:02:30 PST
Committed r287173 (245343@main): <https://commits.webkit.org/245343@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 447413 [details].
Comment 6 Radar WebKit Bug Importer 2021-12-16 22:03:20 PST