[llvm-bugs] [Bug 33974] New: -Wunreachable-code/-Wunreachable-code-return is easily fooled by do{..}while(false) / macro
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Jul 28 05:04:50 PDT 2017
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: unassignedclangbugs at nondot.org
Reporter: lebedev.ri at gmail.com
CC: llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170728/fdac77b3/attachment.html>
More information about the llvm-bugs
mailing list