On Thu, 30 Nov 2023, Ties Klappe via Gcc wrote:

> When reading section 6.7.3.1 of the C standard (quoted below) about
> the *restrict
> *type qualifier, the first section talks about *ordinary identifiers*.
> These are defined in section 6.2.3, and exclude members of structures.
> 
> Let D be a declaration of an ordinary identifier that provides a means of
> > designating an object P as a restrict-qualified pointer to type T.
> 
> 
> I would assume that this means that in the code excerpt below the function
> *h* cannot be optimized by substituting the load of *b.p *for *10*, as the
> standard does not specify what it means for a struct member to be restrict
> qualified. However, the code is still optimized by gcc (but not Clang), as
> can be seen here: https://godbolt.org/z/hEnKKoaae
> 
> struct bar {
> int* restrict p;
> int* restrict q;
> };
> 
> int h(struct bar b) {

In this code, 'b' is the ordinary identifier; "struct bar b" is the 
declaration D.  The declaration does not itself need to have pointer type.

-- 
Joseph S. Myers
jos...@codesourcery.com

Reply via email to