-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Closed
Closed
Copy link
Labels
clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerfalse-positiveWarning fires when it should notWarning fires when it should not
Description
Clang does not appear to be able to deduce that a function that always throws is effectively [[noreturn]], not even in seemingly trivial cases. Consider this:
void throwError(const std::string& msg){
throw std::runtime_error(msg);
}
int ensureZero(const int i){
if (i == 0) return 0;
throwError("ERROR");
}
Compiling with -Wall -Wextra -O3 -std=c++2c
yields a false positive warning:
warning: non-void function does not return a value in all control paths [-Wreturn-type]
Metadata
Metadata
Assignees
Labels
clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerfalse-positiveWarning fires when it should notWarning fires when it should not