Mixing up variables when working with strings does not trigger a warning.

Example:

int main(void)
{
int plen;
char *ptr;

plen[ptr]='\0'; /* (char*)'th element of an int */

return 0;
}

in line 6, plen[ptr]='\0';, plen is implicitly casted to a pointer and ptr is
implicitly casted to an unsigned. At least when casting the int to a pointer,
there should be a warning. 

This behavior can be reproduced in, at least, versions 2.95, 3.2.3 and 4.1.2 of
gcc. Adding -Wall -g -ansi -pedantic -std=c99 does not help.


-- 
           Summary: no warning on implicit cast from int to pointer
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: christoph dot wintersteiger at inf dot ethz dot ch
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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

Reply via email to