[Bug c/44322] New: Bogus warning when assigning pointer-to-array with both "const" and "restrict"

r dot c dot poss at uva dot nl gcc-bugzilla@gcc.gnu.org
Sat May 29 13:24:00 GMT 2010


The following code is valid according to C99:

void * restrict const a[2];
void * restrict const (*p2)[2];

void foo(void) {
   p2 = &a;
}

However GCC complains with:

a.c: In function 'foo':
a.c:14:7: warning: assignment from incompatible pointer type

If either "const" or "restrict" (or both) is omitted from the declaration of 
"a" and "p", no warning is generated.

Despite the warning, code generation and optimization behave properly.

FYI, Clang 1.0.2 accepts this code without warning.


-- 
           Summary: Bogus warning when assigning pointer-to-array with both
                    "const" and "restrict"
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: r dot c dot poss at uva dot nl
 GCC build triplet: x86_64-apple-darwin10
  GCC host triplet: x86_64-apple-darwin10
GCC target triplet: x86_64-apple-darwin10


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44322



More information about the Gcc-bugs mailing list