Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Answer

Post Timeline

added 112 characters in body
Source Link
Eric Postpischil
  • 234k
  • 15
  • 200
  • 383

But what I learned before is that,... then all accesses to that object in that block must be performed via P;...

The definition of restrict in C 2011 6.7.3.1 does not say that. It does not contain the word "performed" at all. This text is not from the standard. You do not say where you learned this from. It is incorrect unless you take "via" to include indirect uses of the restricted pointer, as when P has been assigned to another pointer N.

  1. Is my program strictly in line with the standard (not undefined behavior)?

*N=20; conforms to the requirement stated in the standard that "Every other lvalue used to access the value of X shall also have its address based on P."

  1. If my program is correct, does this mean that the object pointed to by the pointer modified by 'restrict' can be accessed using other ordinary pointers?

The object may be accessed by other pointers that are based on P. Accessing it through pointer (or any lvalue) not based on P would not conform to the rules in 6.7.3.1.

If my program is wrong, then how should we understand the words in the C 2011 standard?

The words in question are not those of the C standard; they are some other words you did not cite the source for.

But what I learned before is that,... then all accesses to that object in that block must be performed via P;...

The definition of restrict in C 2011 6.7.3.1 does not say that. It does not contain the word "performed" at all. This text is not from the standard. You do not say where you learned this from. It is incorrect.

  1. Is my program strictly in line with the standard (not undefined behavior)?

*N=20; conforms to the requirement stated in the standard that "Every other lvalue used to access the value of X shall also have its address based on P."

  1. If my program is correct, does this mean that the object pointed to by the pointer modified by 'restrict' can be accessed using other ordinary pointers?

The object may be accessed by other pointers that are based on P. Accessing it through pointer (or any lvalue) not based on P would not conform to the rules in 6.7.3.1.

If my program is wrong, then how should we understand the words in the C 2011 standard?

The words in question are not those of the C standard; they are some other words you did not cite the source for.

But what I learned before is that,... then all accesses to that object in that block must be performed via P;...

The definition of restrict in C 2011 6.7.3.1 does not say that. It does not contain the word "performed" at all. This text is not from the standard. You do not say where you learned this from. It is incorrect unless you take "via" to include indirect uses of the restricted pointer, as when P has been assigned to another pointer N.

  1. Is my program strictly in line with the standard (not undefined behavior)?

*N=20; conforms to the requirement stated in the standard that "Every other lvalue used to access the value of X shall also have its address based on P."

  1. If my program is correct, does this mean that the object pointed to by the pointer modified by 'restrict' can be accessed using other ordinary pointers?

The object may be accessed by other pointers that are based on P. Accessing it through pointer (or any lvalue) not based on P would not conform to the rules in 6.7.3.1.

If my program is wrong, then how should we understand the words in the C 2011 standard?

The words in question are not those of the C standard; they are some other words you did not cite the source for.

Source Link
Eric Postpischil
  • 234k
  • 15
  • 200
  • 383

But what I learned before is that,... then all accesses to that object in that block must be performed via P;...

The definition of restrict in C 2011 6.7.3.1 does not say that. It does not contain the word "performed" at all. This text is not from the standard. You do not say where you learned this from. It is incorrect.

  1. Is my program strictly in line with the standard (not undefined behavior)?

*N=20; conforms to the requirement stated in the standard that "Every other lvalue used to access the value of X shall also have its address based on P."

  1. If my program is correct, does this mean that the object pointed to by the pointer modified by 'restrict' can be accessed using other ordinary pointers?

The object may be accessed by other pointers that are based on P. Accessing it through pointer (or any lvalue) not based on P would not conform to the rules in 6.7.3.1.

If my program is wrong, then how should we understand the words in the C 2011 standard?

The words in question are not those of the C standard; they are some other words you did not cite the source for.

lang-c

AltStyle によって変換されたページ (->オリジナル) /