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

            Bug ID: 88014
           Summary: Restrict/C2X/N2260 Restricted function argument
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mcccs at gmx dot com
  Target Milestone: ---

N2260 ( http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2260.pdf )
has been integrated to C2X, according to
https://gustedt.wordpress.com/2018/11/12/c2x/ .

Code taken from the paper above:


#include <stdio.h>
void g(int **a, int *b)
{
*a = b;
}
int foo(int * restrict p, int *q)
{
g(&q, p); // effectively q = p
*p = 1;
*q = 2;
return *p + *q;
}
int main()
{
int x, y;
printf("%d", foo(&x, &y));
return 0;
}

Args: -O0

Result: 4 (correct)

Args: -fno-inline -O3

Result: 3 (incorrect)

Reply via email to