https://llvm.org/bugs/show_bug.cgi?id=31675
Bug ID: 31675 Summary: clang incorrectly assumes extern addresses cannot be identical Product: clang Version: unspecified Hardware: PC OS: Linux Status: NEW Severity: normal Priority: P Component: -New Bugs Assignee: unassignedclangb...@nondot.org Reporter: bruen...@google.com CC: llvm-bugs@lists.llvm.org Classification: Unclassified Clang seems to assume that extern addresses cannot be identical. If we try to compare two assembly labels, clang does not bother to emit a comparison and assumes they are different: -------------------------------------------------- #include <stdio.h> extern void * asm_label; extern void * asm_label2; int main() { __asm("asm_label: asm_label2:"); if (&asm_label != &asm_label2) puts("bug"); else puts("no bug"); return 0; } -------------------------------------------------- # /usr/bin/clang clangbug.c -o clangbug && ./clangbug bug # /usr/bin/gcc clangbug.c -o clangbug && ./clangbug no bug Examining the generated code, there is no comparison at all and simply a call to puts("bug"), even at -O0. # /usr/bin/clang --version clang version 3.5.0 (tags/RELEASE_350/final) Target: x86_64-redhat-linux-gnu Thread model: posix More recent versions of clang have the same behavior, including a recent clang built from sources at r290297. Xref https://github.com/DynamoRIO/dynamorio/issues/2124 where a recent clang (r290297 in fact) extends this problem to static const copies of extern addresses. Is there something in the C language spec that allows clang to make this assumption? This does not seem limited to assembly labels: presumably function aliases could hit the same problem (certainly it happens if these are not "extern void *" but rather declared as extern functions which are supplied in a separately compiled file). -- 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