No, part 2 is not in order.
The specific part of the standard is 6.7.3.1/4. This section is rather dense and takes several readings, but P is a bounding pointer, and X is some object that it is accessing, and which is changing. So in your example P is fooPtr and X is foo . Then:
Each other value used to access the value of X also has its own address based on P.
"based" is defined in the previous paragraph and summarizes, lvalue foo does not have its address based on the restriction pointer P. Thus, the rule is violated when accessing the object foo through its own name.
Part 3 is not suitable for the same reason, the value lvalue *fooPtr2 also not based on P, but is also used to access X.
I say βout of orderβ - to be precise, the combination of 1 + 2 causes the behavior to be undefined, like the combination of 1 + 3. As long as you do not actually access the object using the restriction pointer, none of the definition of the restriction βkicksβ. If you want you to be able to remove Part 1, keep an unused restriction pointer, then 2 and 3 will be fine.
source share