https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107561
--- Comment #17 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to Jakub Jelinek from comment #16) > (In reply to Richard Biener from comment #15) > > The compiler doesn't know that the allocation function cannot clobber *this. > > The C++ frontend tries to communicate this by making 'this' restrict > > qualified > > and we make use of that info, but for calls we do not know how to use the > > info. > > > > Maybe we can special-case directly the actual parameter case and compute > > the restrictness info for the call arguments. The canonical example is > > > > void bar (void); > > struct X { > > X (int); > > int i; > > int j; > > }; > > > > X::X(int k) > > { > > i = k; > > bar (); > > j = i != k; > > } > > > > where if I understand you correctly, bar () is not allowed to modify *this > > (unless I pass it an argument to it, of course), even if *this is for > > example > > Why? Because it is a constructor and the object isn't fully constructed yet > at that point? For normal methods I certainly don't see anything that would > preclude such modifications. The canonical C example would be void bar (void); void foo (struct X * restrict this, int k) { this->i = k; bar (); this->j = i != k; } where as I understand bar () cannot modify what *this points to since it cannot build a proper derived access from 'this' (unless I pass it to bar). The C++ frontend annotates 'this' with restrict. For my example I get void X::X (struct X * const this, int k) { # PT = { D.2806 } (nonlocal, restrict) struct X * const this_5(D) = this; int k_7(D) = k; int _1; bool _2; int _3; <bb 2> : MEM[(struct X *)this_5(D) clique 1 base 1] ={v} {CLOBBER}; MEM[(struct X *)this_5(D) clique 1 base 1].i = k_7(D); # USE = nonlocal escaped # CLB = nonlocal escaped bar (); _1 = MEM[(struct X *)this_5(D) clique 1 base 1].i; _2 = _1 != k_7(D); # RANGE [irange] int [0, 1] NONZERO 0x1 _3 = (int) _2; MEM[(struct X *)this_5(D) clique 1 base 1].j = _3; return; }