https://gcc.gnu.org/bugzilla/show_bug.cgi?id=76262

Arthur O'Dwyer <arthur.j.odwyer at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |arthur.j.odwyer at gmail dot 
com

--- Comment #5 from Arthur O'Dwyer <arthur.j.odwyer at gmail dot com> ---
GCC still has the buggy behavior as of 2021. This bug should be reopened.

GCC's behavior here disagrees with all of Clang, ICC, MSVC, and common sense.

// https://godbolt.org/z/GKxh8P
struct A {};
struct B {
    B(const B&);
    explicit B(std::initializer_list<A>);
    operator A() const;
};

extern B b;
void test() {
    auto a{b};  // constructs as if by `B a = { static_cast<A>(b) }`, not `B a
= b`
}

I recently observed real teaching materials claiming that brace-initialization
didn't work for copies -- if you want to invoke the copy constructor you MUST
use parentheses -- and giving essentially this bug as the reason. (They
apparently didn't realize that this behavior was unique to GCC, and the subject
of a bug report.)

Reply via email to