Discussed in #207
Originally posted by ilazaric October 3, 2026
Issue Summary
If a function marked with [[noreturn]] construct an object whose constructor is marked [[noreturn]],
this is not recognized, and an erroneous warning is emitted.
Reproducing Source Code
struct A {
[[noreturn]] A() { throw 123; }
};
struct B {
[[noreturn]] B() { A{}; }
};
[[noreturn]] void g() { A{}; }
Command-line Options
cpfe repro.cpp
Type of Issue
[Front End] This code SHOULD NOT warn with these options.
Additional Details
In the example, both B::B() and g() cause the warning to be emitted,
and it is clear they can't actually return because of A::A().
Compiler output:
"<source>", line 6: warning: function declared with "noreturn" does return
[[noreturn]] B() { A{}; }
^
"<source>", line 9: warning: function declared with "noreturn" does return
[[noreturn]] void g() { A{}; }
^
Godbolt: https://godbolt.org/z/nGvdedcsG
Also noting that the attribute on A::A() is not fully ignored,
if we remove the throw it warns there (as expected/correct).
Reproducing (Standard) Configuration(s)
linux-gcc-release
Reproducing (Non-standard) Configuration
No response
I acknowledge that:
Discussed in #207
Originally posted by ilazaric October 3, 2026
Issue Summary
If a function marked with
[[noreturn]]construct an object whose constructor is marked[[noreturn]],this is not recognized, and an erroneous warning is emitted.
Reproducing Source Code
Command-line Options
cpfe repro.cpp
Type of Issue
[Front End] This code SHOULD NOT warn with these options.
Additional Details
In the example, both
B::B()andg()cause the warning to be emitted,and it is clear they can't actually return because of
A::A().Compiler output:
Godbolt: https://godbolt.org/z/nGvdedcsG
Also noting that the attribute on
A::A()is not fully ignored,if we remove the throw it warns there (as expected/correct).
Reproducing (Standard) Configuration(s)
linux-gcc-release
Reproducing (Non-standard) Configuration
No response
I acknowledge that:
LICENSE.txtfile in my.zipor.tar.gzupload. If I included aLICENSE.txtfile, any tests created using the reproducing source code will be governed by the terms of the license I provided instead.