Open
Description
I was confused about what was happening with https://discourse.llvm.org/t/detect-if-type-is-complete-not-forward-decl/87107
It looks like we're trying to evaluate requires
constraints on constructor methods during class synthesis rather than on use of the constructor, but I believe evaluation of these constraints should not occur until synthesis of the constructor.
https://godbolt.org/z/eM5dx99sY
#include <type_traits>
struct Dummy;
template<class T> struct MyTemplate {
T*p;
MyTemplate()
requires (std::is_default_constructible_v<T>)
{ }
};
class MyTest {
MyTemplate<struct Dummy> data;
public:
MyTest();
void someFn() { }
};
MyTest test;
int main() {
test.someFn();
}
struct Dummy { int a; };
MyTest::MyTest() { }
This happens for all the constructors, even those that are not used - a minor modification: https://godbolt.org/z/YTK9c6adj - shows that the requires clause is evaluated for all constructors, even those that are not used in the TU:
#include <type_traits>
struct Dummy;
template<class T> struct MyTemplate {
T*p;
MyTemplate();
MyTemplate(float f)
requires (std::is_default_constructible_v<T>)
{ }
};
class MyTest {
MyTemplate<struct Dummy> data;
public:
MyTest();
void someFn() { }
};
MyTest test;
int main() {
test.someFn();
}
struct Dummy { int a; };
MyTest::MyTest() { }