-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Open
Labels
clangClang issues not falling into any other categoryClang issues not falling into any other categoryconfirmedVerified by a second partyVerified by a second party
Description
While working on QEMU, we recently exposed a missed constant folding with clang -O0.
Given this code:
$ cat main.c
extern int f(void);
int main(int argc) {
if (argc && 0)
f();
}$ clang -O0 main.c
/usr/bin/ld: /tmp/main-19bcf0.o: in function `main':
main.c:(.text+0x21): undefined reference to `f'Since argc && 0 is always false, it could be expected (though not required by the standard) that branch is eliminated and thus, f should not be referenced. Some code on QEMU expect dead code elimination to happen, to not cross reference some symbols.
When changing condition to (0 && argc), the branch is removed as expected.
Original discussion on QEMU side: https://lore.kernel.org/qemu-devel/[email protected]/
Metadata
Metadata
Assignees
Labels
clangClang issues not falling into any other categoryClang issues not falling into any other categoryconfirmedVerified by a second partyVerified by a second party