https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65330
Bug ID: 65330 Summary: restrict should be considered when folding through references from global vars Product: gcc Version: 5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: hubicka at gcc dot gnu.org In the following testcase the restrict should be taken into account when folding testrestrict. const int *varptr=&var; const int *__restrict__ varptr2=&var; int *__restrict__ varptr3 = &var; int *__restrict__ varptr4 = &var; int * return_valptr(int i) { return varptr[i]; } int * __restrict__ return_valptr2(int i) { return varptr2[i]; } int testrestrict () { int *ptr = return_valptr (0); *ptr = 0; *varptr3 = 1; return *ptr; } int testrestrict2 () { int *ptr = return_valptr2 (0); *ptr = 0; *varptr3 = 1; return *ptr; } int testrestrict4 () { *varptr4 = 0; *varptr3 = 1; return *varptr4; }