Skip to content

confusing -Wunreachable-code calling a [[noreturn]] function with a non-POD return type #152477

@firewave

Description

@firewave
#include <stdexcept> #include <string> [[noreturn]] int func(); [[noreturn]] std::string err(); void f(int i) { if (i == 0) { } else if (i == 1) { func(); } else { err(); } }
<source>:15:9: warning: code will never be executed [-Wunreachable-code] 15 | err(); | ^~~~~ 

https://godbolt.org/z/ffKzT8MfP

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerconfirmedVerified by a second partyfalse-positiveWarning fires when it should not

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions