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

Reply via email to