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

glisse at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon May 14 10:17:00 GMT 2018


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

--- Comment #22 from Marc Glisse <glisse at gcc dot gnu.org> ---
(In reply to rguenther@suse.de from comment #21)
> 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.


How is that different from the C

void Foo_const(Foo*const restrict t)
{
  Foo *x = t;
  x->a = 1;
  t->a = 2;
}

, which seems valid to me?


More information about the Gcc-bugs mailing list