https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99969
Bug ID: 99969 Summary: g++ incorrectly thinks a private destructor is available Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: Steffen.Kiess at ipvs dot uni-stuttgart.de Target Milestone: --- Created attachment 50527 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50527&action=edit Test case The attached test case will fail to compile (because g++ chooses thinks the first overload should match, even though the destructor of C is private and "delete std::declval<T *>()" therefore should note compile). This is somehow related to the fact the "decltype(test((C *)nullptr))" is referred to from a template context before it is used in main() (if the struct S is removed or moved below the main() function the code will compile). The problem occurs with gcc 10.2.0 (but also with older versions, at least back to 4.9).