Bug 109307 - [13 Regression] constructors fails typecheck on initializer list assignment
Summary: [13 Regression] constructors fails typecheck on initializer list assignment
Status: RESOLVED DUPLICATE of bug 109247
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 13.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-03-27 22:27 UTC by Sergei Trofimovich
Modified: 2023-03-30 16:32 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sergei Trofimovich 2023-03-27 22:27:14 UTC
Seems to be this week's regression. On gcc-13 webkitgtk-2.38.5 fails to uild as:

/home/slyfox/n/webkitgtk-2.38.5/Source/WebCore/platform/graphics/SourceBrush.cpp:68:78: error: converting to 'std::optional<WebCore::SourceBrush::Brush>' from initializer list would use explicit constructor 'constexpr std::optional<_Tp>::optional(_Up&&) [with _Up = WebCore::SourceBrush::Brush::LogicalGradient; typename std::enable_if<__and_v<std::__not_<std::is_same<std::optional<_Tp>, typename std::remove_cv<typename std::remove_reference<_Iter>::type>::type> >, std::__not_<std::is_same<std::in_place_t, typename std::remove_cv<typename std::remove_reference<_Iter>::type>::type> >, std::is_constructible<_Tp, _Up>, std::__not_<std::is_convertible<_Iter, _Iterator> > >, bool>::type <anonymous> = false; _Tp = WebCore::SourceBrush::Brush]'
   68 |     m_brush = { Brush::LogicalGradient { WTFMove(gradient), spaceTransform } };
      |                                                                              ^

gcc-12 is fine. I think this is the cmall example that illustrates the failure:

// $ cat SourceBrush.cpp
#include <optional>
#include <variant>

class RefGradient {};
class RefPattern {};
class AffineTransform {};

class SourceBrush {
  public:
    struct Brush {
        struct LogicalGradient {
            RefGradient gradient;
            AffineTransform spaceTransform;
        };

        std::variant<LogicalGradient, RefPattern> brush;
    };

    void setGradient(RefGradient &&, const AffineTransform & spaceTransform = { });
    void setPattern(RefPattern &&);

  private:
    std::optional<Brush> m_brush;
};

void SourceBrush::setGradient(RefGradient&& gradient, const AffineTransform& spaceTransform)
{
    m_brush = { Brush::LogicalGradient { std::move(gradient), spaceTransform } };
}

void SourceBrush::setPattern(RefPattern&& pattern)
{
    m_brush = { std::move(pattern) };
}


gcc-12 works:

$ g++-12.2.0 SourceBrush.cpp -c -std=c++20
<ok>

$ g++-13.0.0 SourceBrush.cpp -c -std=c++20
SourceBrush.cpp: In member function 'void SourceBrush::setGradient(RefGradient&&, const AffineTransform&)':
SourceBrush.cpp:28:80: error: converting to 'std::optional<SourceBrush::Brush>' from initializer list would use explicit constructor 'constexpr std::optional<_Tp>::optional(_Up&&) [with _Up = SourceBrush::Brush::LogicalGradient; typename std::enable_if<__and_v<std::__not_<std::is_same<std::optional<_Tp>, typename std::remove_cv<typename std::remove_reference<_Iter>::type>::type> >, std::__not_<std::is_same<std::in_place_t, typename std::remove_cv<typename std::remove_reference<_Iter>::type>::type> >, std::is_constructible<_Tp, _Up>, std::__not_<std::is_convertible<_Up, _Tp> > >, bool>::type <anonymous> = false; _Tp = SourceBrush::Brush]'
   28 |     m_brush = { Brush::LogicalGradient { std::move(gradient), spaceTransform } };
      |                                                                                ^
SourceBrush.cpp: In member function 'void SourceBrush::setPattern(RefPattern&&)':
SourceBrush.cpp:33:36: error: converting to 'std::optional<SourceBrush::Brush>' from initializer list would use explicit constructor 'constexpr std::optional<_Tp>::optional(_Up&&) [with _Up = RefPattern; typename std::enable_if<__and_v<std::__not_<std::is_same<std::optional<_Tp>, typename std::remove_cv<typename std::remove_reference<_Iter>::type>::type> >, std::__not_<std::is_same<std::in_place_t, typename std::remove_cv<typename std::remove_reference<_Iter>::type>::type> >, std::is_constructible<_Tp, _Up>, std::__not_<std::is_convertible<_Up, _Tp> > >, bool>::type <anonymous> = false; _Tp = SourceBrush::Brush]'
   33 |     m_brush = { std::move(pattern) };
      |                                    ^

$ g++-13.0.0 -v
Using built-in specs.
COLLECT_GCC=/<<NIX>>/gcc-13.0.0/bin/g++
COLLECT_LTO_WRAPPER=/<<NIX>>/gcc-13.0.0/libexec/gcc/x86_64-unknown-linux-gnu/13.0.1/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with:
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 13.0.1 20230326 (experimental) (GCC)
Comment 1 Jakub Jelinek 2023-03-27 22:29:45 UTC
Dup.

*** This bug has been marked as a duplicate of bug 109247 ***