https://llvm.org/bugs/show_bug.cgi?id=22986
Bug ID: 22986
Summary: distinct subclass types aliasing false-positive
Product: clang
Version: 3.6
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Classification: Unclassified
Pointers to distinct subclass types can't alias, even if they share a base
class.
But the code generated here indicates clang thinks they can, as it doesn't
collapse the return expression into a constant 4 (and even re-fetches
t1->common):
struct base {int common;};
struct sub1 : base {} *t1;
struct sub2 : base {} *t2;
int fn(void)
{
t1->common = 1;
t2->common = 2;
return t1->common + 3;
}
Compiled -O3, this generates:
fn(): # @fn()
movq t1(%rip), %rax
movl $1, (%rax)
movq t2(%rip), %rcx
movl $2, (%rcx)
movl (%rax), %eax
addl $3, %eax
retq
vs. GCC's:
fn():
movq t1(%rip), %rax
movl $1, (%rax)
movq t2(%rip), %rax
movl $2, (%rax)
movl $4, %eax
ret
Note that it doesn't matter that the two subclasses had the same layout; the
exact same code is generated even if they're different:
struct base {int common;};
struct sub1 : base {int foo;} *t1;
struct sub2 : base {char bar;} *t2;
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs