https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90803
Bug ID: 90803
Summary: gcc accepts invalid code
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: zhonghao at pku dot org.cn
Target Milestone: ---
My gcc is 10.0.0, and the code is:
struct S {};
struct T : S {};
void foo(T *t) { t->~S(); }
gcc accepts the code, but icc, msvc, and clang all reject it.
msvc:
<source>(3): error C2300: 'T': class does not have a destructor called '~S'
Compiler returned: 2
icc:
source>(3): error: invalid destructor name for type "T"
void foo(T *t) { t->~S(); }
^
compilation aborted for <source> (code 2)
Compiler returned: 2
clang:
source>:3:22: error: destructor type 'S' in object destruction expression does
not match the type 'T' of the object being destroyed
void foo(T *t) { t->~S(); }
^
<source>:1:8: note: type 'S' is declared here
struct S {};
^
1 error generated.
Compiler returned: 1