https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116251
Bug ID: 116251
Summary: Invalid use of pseudo destructor is not diagnosed in
unevaluated contexts
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: luigighiron at gmail dot com
Target Milestone: ---
The following code is incorrectly accepted by GCC:
using T=int;
T i;
decltype(i.~T)foo();
typeid(i.~T);
noexcept(i.~T);
The last three lines are invalid, and GCC accepts them without warning.
Additionally, the following is also accepted with a warning (with the default
warnings) and is similarly invalid:
sizeof(i.~T);
All of these uses of the pseudo destructor are invalid and should be diagnosed.
Clang diagnoses all of these correctly. MSVC does not diagnose the first three
cases (but it does diagnose the fourth case since it doesn't support
sizeof(void)) and allows these invalid uses even in evaluated contexts.