Skip to content

Spurious warning in C++11 when attempting to define a constexpr destructor #163683

@shafik

Description

@shafik

In C++11 we are not allowed to declare/define a constexpr destructor, we obtain the proper diagnostic for this in clang but if we attempt to also define is then clang provides a completely spurious diagnostic as well: https://godbolt.org/z/Geq7Th7oh

struct A {
  constexpr ~A(){}
};

Diagnostic:

<source>:2:3: error: destructor cannot be declared constexpr
    2 |   constexpr ~A(){}
      |   ^
<source>:2:13: error: constexpr function's return type 'void' is not a literal type
    2 |   constexpr ~A(){}
      |             ^

The second diagnostic is just not helpful at all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzer

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions