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

--- Comment #2 from Jan Schultke <janschultke at googlemail dot com> ---
(In reply to Jiang An from comment #1)
> The restriction agains aliasing was intended, see
> https://cplusplus.github.io/CWG/issues/2271.html.
> 
> The status quo seems to be that in the body of `A::A(int &x)`, compilers can
> assume that the value of `x` won't be changed by a modification on `*this`,
> but not the other way around.

Then this status quo is not correctly implemented, because in the example, GCC
assumes that a change of `x` (see `x = 5`) cannot alter `this->i` (see `i == 0`
assumed to be always true).

It is not enough to put `__restrict` on the parameters; a much weaker modifier
must be used for this purpose. At most, a "one-way `__restrict`" must be used,
if such a thing exists.

Reply via email to