Skip to content

[clang][trunk] compiler crashes if the first parameter of a member operator delete is in class type #96191

@Snape3058

Description

@Snape3058

detailed execution result on godbolt

This bug was discovered when I was studying the usage of std::destorying_delete_t.
After removing the first parameter of a pointer type, the compiler crashes.

In the example below, std::destorying_delete_t is simplified to struct S for the sake of debugging.

struct S {};
struct T {
  void operator delete(S) {}
};

void foo(T *t) { delete t; }

Pretty stack dump:

1.	<source>:6:26: current parser token ';'
2.	<source>:6:16: parsing function body 'foo'
3.	<source>:6:16: in compound statement ('{}')

Crashed in function clang::Sema::ActOnCXXDelete(clang::SourceLocation, bool, bool, clang::Expr*)
when checking QualType ParamType, which is not a pointer and its getPointeeType returns an empty QualType.

QualType ParamType = OperatorDelete->getParamDecl(0)->getType();
if (!IsVirtualDelete && !ParamType->getPointeeType()->isVoidType()) {

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions