https://bugs.llvm.org/show_bug.cgi?id=44508
Bug ID: 44508
Summary: Wrong optimization of comparison of addresses of empty
structs
Product: new-bugs
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: new bugs
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected]
Wrong optimization of comparison of addresses of empty structs:
----------------------------------------------------------------------
#include <stdio.h>
int main()
{
struct {} x, y;
void *p = &x;
void *q = &y;
printf("eq1: %d\n", p == q);
unsigned long u = (unsigned long)p;
unsigned long v = (unsigned long)q;
printf("diff: %lu\n", u - v);
printf("eq2: %d\n", u == v);
}
----------------------------------------------------------------------
$ clang -std=c11 -Wall -O3 test.c && ./a.out
eq1: 0
diff: 0
eq2: 0
----------------------------------------------------------------------
clang x86-64 version: clang version 10.0.0
(https://github.com/llvm/llvm-project.git
8647a72c4a52e0386c0397ce3fbd38121c18b873)
----------------------------------------------------------------------
Empty structs is a gcc extension (they are UB according to C11, 6.7.2.1p8) but,
nevertheless, I think zero `diff` should imply non-zero eq2 and eq1.
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs