https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107179
Bug ID: 107179
Summary: requires-expression gives hard error for inaccessible
constructor
Product: gcc
Version: 12.2.1
Status: UNCONFIRMED
Keywords: rejects-valid
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
Target Milestone: ---
template<bool B> struct bool_constant { static constexpr bool value = B; };
template<typename T>
struct is_implicitly_default_constructible
: bool_constant<requires (void (*f)(const T&)) { f({}); }>
{ };
class X {
X();
public:
X(int);
};
static_assert( !is_implicitly_default_constructible<X>::value );
This should compile with -std=c++20 but doesn't:
conv.cc: In instantiation of 'struct is_implicitly_default_constructible<X>':
conv.cc:14:55: required from here
conv.cc:5:53: error: 'X::X()' is private within this context
5 | : bool_constant<requires (void (*f)(const T&)) { f({}); }>
| ~^~~~
conv.cc:9:3: note: declared private here
9 | X();
| ^
conv.cc:14:16: error: static assertion failed
14 | static_assert( !is_implicitly_default_constructible<X>::value );
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~