I created the following test code:

int x;
inline myfun (void*m)
{
  x = *(int *)m;
}
int
bar (const void *p)
{
  myfun ((void *)p);
}

If I compile it as:

gcc -c test.c 

I don't get a warning. However:

gcc -O -c test.c

produces the following:

test.c: In function ‘bar’:
test.c:9: warning: passing argument 1 of ‘myfun’ discards qualifiers from
pointer target type

It seems that this error is affected by inlining of myfun. I checked the gcc
head version and warning does not appear there. 4.1.2 also does not have it.


-- 
           Summary: cast from "const void *" into "void *" produces a
                    warning
           Product: gcc
           Version: 4.2.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: nenad at intrepid dot com
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64


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

Reply via email to