This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/81008] missing optimization for restricted pointers passed to functions


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81008

--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
Restrict imposes additional constraints even on accesses to objects via
non-restricted pointers.  The one relevant to this report is in 6.7.3.1, p4:

  -4-  During each execution of B, let L be any lvalue that has &L based on P. 
If L is used to access the value of the object X that it designates, and X is
also modified (by any means), then the following requirements apply: [...]
Every other lvalue used to access the value of X shall also have its address
based on P. ...

The example in C11 6.7.3.1 illustrates them:

  -7-  EXAMPLE 1   The file scope declarations

            int * restrict a;
            int * restrict b;
            extern int c[];

       assert that if an object is accessed using one of a, b, or c, and that
object is modified anywhere in the program, then it is never accessed using
either of the other two.

Applying this to the program in comment #1 means that since *p is used to
access object X (i.e., p = &X), if X were to be modified by the call to f() it
would have to be through a pointer based on p, not by some other pointer
obtained from &X prior to the execution of g().  That such a pointer would not
be based on p is explained in paragraphs 1 through 3 of the same section.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]