On Fri, May 18, 2018 at 09:02:08AM -0400, Nathan Sidwell wrote:
> On 05/18/2018 08:53 AM, Marc Glisse wrote:
> 
> > As long as you do not dereference ptr in the constructor, that shouldn't
> > contradict 'restrict'. The PR gives this quote from the standard:
> > 
> > "During the construction of an object, if the value of the object or any
> > of its subobjects is accessed through a glvalue that is not obtained,
> > directly or indirectly, from the constructor’s this pointer, the value
> > of the object or subobject thus obtained is unspecified."
> > 
> > which reads quite close to saying that 'this' is restrict.
> Indeed it is, thanks.
> 
> what about comparisons to this?  I thought restrict implied such a
> comparison was 'never the same'?
> 
> ie. if the ctor was:
>   selfie (selfie *ptr) : me (ptr==this ? 0 : ptr) {}

But what is invalid on:
struct S { int foo (S *); int a; } s { 2 };
int S::foo (S *x)
{
  int b = this->a;
  x->a = 5;
  b += this->a;
  return b;
}
int main ()
{
  if (s.foo (&s) != 7)
    abort ();
}

I think if you make this a restrict pointer, this will be miscompiled.

        Jakub

Reply via email to