On Mon, 20 Jan 2020, Joseph Myers wrote: > On Mon, 20 Jan 2020, Alexander Monakov wrote: > > > Hi, > > > > we have this paragraph in the documentation that attempts to prohibit > > something that is allowed by the language. Instead, I think we should > > say that this generally should work and explain that a problem in GCC > > implementation breaks this. > > Is this based on the proposals to adopt a PNVI model (as described in > N2362 / N2363 / N2364) for C2x? Do you have a more detailed analysis of > exactly which issues would need changes in GCC to follow the proposed > PNVI-ae-udi semantics? Setting up a meta-bug in Bugzilla with > dependencies on such issues might be useful, for example - I know there > are existing bugs you've filed or commented on, but it would help to have > a list in a single place of issues for implementing PNVI-ae-udi. > > It's not obvious that documentation relating to things that are > implementation-defined in existing C standard versions, where detailed > memory model questions were not defined, is an appropriate place to > discuss questions of how some optimizations might not follow a more > precise definition proposed for C2x.
My intent was more basic. I observed that the paragraph can be interpreted as saying that if you have a cast 'I1 = (intptr_t) P1', then perform some computations on I1 that do not in any way depend on values of other pointers, then casting the result back can not point to a different object than P1. But that is not very helpful, because this is the case where the user might have used normal pointer arithmetic in the first place. The important cases involve computations that depend on multiple pointers to unrelated objects. I think that the case discussed in the proposed patch is already not ambiguous and does not need further clarifications to the standard. I also think we should provide the users with rationale when imposing such restrictions, and, as Sandra noted, offer a way to work around the problem. However I don't mind dropping the patch if it's not appropriate. Richard, can you share your opinion here? Thanks. Alexander