https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110035
--- Comment #9 from Pontakorn Prasertsuk <ptk.prasertsuk at gmail dot com> --- (In reply to Richard Biener from comment #8) > (In reply to Pontakorn Prasertsuk from comment #7) > > For the LLVM IR code of the snippet I provided, Clang's alias analysis can > > prove that `new` call has no side effect to other memory location. This is > > indicated by `noalias` keyword at the return value of the `new` call > > (_Znwm). > > > > According to Clang's Language Reference: > > "On function return values, the noalias attribute indicates that the > > function acts like a system memory allocation function, returning a pointer > > to allocated storage disjoint from the storage for any other object > > accessible to the caller." > > > > Is this possible for GCC alias analysis pass? > > > MyClass c = a; > > MyClass *b = new MyClass; > > *b = c; > > the point is that 'new' can alter the value of 'a', GCC already knows that > 'b' is distinct from c and a but that's not the relevant thing. It looks > like LLVM creates wrong-code here. In what case can 'new' alter 'a'? I thought memory allocation functions such as 'malloc, 'calloc' and 'new' cannot alias other memory locations than its return value.