[Bug c++/82899] *this in constructors could not alias with reference input parameters of the same type

rguenther at suse dot de gcc-bugzilla@gcc.gnu.org
Mon May 14 07:31:00 GMT 2018


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82899

--- Comment #21 from rguenther at suse dot de <rguenther at suse dot de> ---
On Sat, 12 May 2018, glisse at gcc dot gnu.org wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82899
> 
> --- Comment #20 from Marc Glisse <glisse at gcc dot gnu.org> ---
> Created attachment 44122
>   --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44122&action=edit
> untested middle-end patch
> 
> This works on the testcase, I need to add a comment and run it through the
> testsuite.

Looks good.  Note that in the strict C semantic thing __restrict on
this isn't valid as the following is valid C++:

Foo() __restrict
{
  Foo *x = this;
  x->a = 1;
  this->a = 2;
...
}

but for C restrict you'd have two pointers with same provenance here.

The middle-end handles this situation conservatively and thus the
middle-end approach of effectively handling it as restrict is fine.


More information about the Gcc-bugs mailing list