https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114163
Bug ID: 114163 Summary: Calling member function of an incomplete type compiles in gcc and does not compile in clang and msvc Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jlame646 at gmail dot com Target Milestone: --- The following invalid program(since lambda's body in not complete class context) is compiled by gcc: ``` struct TestClass { void testFinction() {} static TestClass* ptr_; constexpr static auto funcPtr = +[](){ ptr_->testFinction(); }; }; TestClass* TestClass::ptr_ = new TestClass(); int main() { // TestClass::funcPtr(); // delete TestClass::ptr_; return 0; } ``` Demo https://godbolt.org/z/Yhc8MeWW6 First discovered at https://stackoverflow.com/questions/78080083/calling-member-function-of-an-incomplete-type-compiles-in-gcc-and-does-not-compi