Issue 167247
Summary [clang] regression in clang 21: `-Wmissing-noreturn` is emitted for virtual methods
Labels clang
Assignees
Reporter jy-lefort
    Sometimes I feel like I'm the only one in town to compile with `-Weverything`...

Test source:

```
#include <stdexcept>

struct Base {
    virtual ~Base () = default;

    virtual void foo () {
 throw std::runtime_error("this base method does not return");
 }
};
```

Compile:

```
$ clang++ -std=c++23 -Wmissing-noreturn -c test.cxx 
test.cxx:6:18: warning: function 'foo' could be declared with attribute 'noreturn' [-Wmissing-noreturn]
    6 |     virtual void foo () {
      |                  ^
1 warning generated.
```

This warning is obviously spurious: `Base::foo` does indeed not return, but a derived method may return.

The warning is emitted by clang 21.1.4. It did not occur with clang 20.x.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to