https://bugs.llvm.org/show_bug.cgi?id=33974
Bug ID: 33974
Summary: -Wunreachable-code/-Wunreachable-code-return is easily
fooled by do{..}while(false) / macro
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
Assignee: unassignedclangb...@nondot.org
Reporter: lebedev...@gmail.com
CC: llvm-bugs@lists.llvm.org
Code:
void foo();
int main() {
do {
foo();
__builtin_unreachable();
foo();
} while(false);
foo();
return 0;
}
Clang warns only on the second foo() call, but not the last one.
7 : <source>:7:9: warning: code will never be executed [-Wunreachable-code]
foo();
^~~
Such do{stuff}while(false) pattern is used in macros to do some complicated
stuff.
And to add some more fun to it:
void foo();
#define macro() do {\
foo(); \
__builtin_unreachable(); \
foo(); \
} while(false);
int main() {
macro()
foo();
return 0;
}
clang issues no warning whatsoever for this...
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs