Spurious warning in C++11 when attempting to define a constexpr destructor
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
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
```cpp
struct A {
constexpr ~A(){}
};
```
Diagnostic:
```console
:2:3: error: destructor cannot be declared constexpr
2 | constexpr ~A(){}
| ^
: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.
Contributor guide
Research direction
Start by compiling the provided C++11 reproducer and compare Clang's diagnostics with the linked Godbolt example. Trace the semantic-analysis path that diagnoses constexpr destructors, then add or update a regression test for the snippet. Done means only the invalid-destructor diagnostic is emitted, without the spurious return-type diagnostic.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100