https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109159
Bug ID: 109159
Summary: explicit constructor is used in copy-initialization
Product: gcc
Version: 12.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: fchelnokov at gmail dot com
Target Milestone: ---
The following code must be accepted (as it does in Clang and MSVC):
struct A {
A( float ) {}
template<class U>
explicit A( U ) {}
};
template<class T>
concept CopyFromIntList = requires( T t ) { t = { 1 }; };
static_assert( !CopyFromIntList<A> );
because 't = {1}' is invalid: chosen constructor is explicit in
copy-initialization.
But in GCC static_assert fails. Online demo:
https://gcc.godbolt.org/z/Pf47E6dno