https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120597
Bug ID: 120597 Summary: False positive -Wreturn-type after std::unreachable() or __builtin_unreachable() Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: janschultke at googlemail dot com Target Milestone: --- Consider this example (https://godbolt.org/z/oK7nKPjbP): > struct S { ~S(); }; > > int f(); > > int g() { > S s; > if (f()) return 0; > __builtin_unreachable(); > f(); // warning: control reaches end of non-void function [-Wreturn-type] > } Normally, placing a function call after __builtin_unreachable() has no effect on whether -Wreturn-type is emitted, but a combination of non-trivial destruction and the conditional return beforehand result in a warning anyway. This is obviously a false positive because control cannot reach the end of a function if we unconditionally call __builtin_unreachable() somewhere in the middle.