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

            Bug ID: 68162
           Summary: Incompatible pointer type using a typedef
           Product: gcc
           Version: 5.2.1
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: campus at ntop dot org
  Target Milestone: ---

Created attachment 36623
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36623&action=edit
the preprocessed file

I'm getting a warning about incompatible pointer types that is not expected. 
I've extracted the problem to a small example that reproduces the error:


typedef const double ConstSpiceDouble;

void foo(const double (*)[3]); 

int main(int argc, char **argv) {

  double a[3][3] = {{1,2,3},{1,2,3},{1,2,3}};

  foo((ConstSpiceDouble (*)[3])a);

  return 0;
}


The compiler reports this:

$~/gcc/bin/gcc --version
gcc (Debian 5.2.1-22) 5.2.1 20151010

~/gcc/bin/gcc -Wall -c typedef.c
typedef.c: In function ‘main’:
typedef.c:13:7: warning: passing argument 1 of ‘foo’ from incompatible pointer
type [-Wincompatible-pointer-types]
   foo((ConstSpiceDouble (*)[3])a);
       ^
typedef.c:7:6: note: expected ‘const double (*)[3]’ but argument is of type
‘const ConstSpiceDouble (*)[3] {aka const double (*)[3]}’
 void foo(const double (*)[3]); 
      ^

The note from gcc is especially troubling since it seems to admit that the two
types are identical, yet it complains anyway.

Reply via email to