sizeof array-typed function parameter: Warning possible?

Claus Fischer claus.fischer@clausfischer.com
Wed Aug 13 18:11:00 GMT 2003


I just tripped over this:
   void f(char x[100])
   {
       snprintf(x,sizeof(x),"foobar");
   }
I understand that section 6.7.5.3 #6 of my draft C standard
means the compiler is right, as usual :-)

I guess it's not possible to devise a very clever GCC compiler
warning that detects such nasty programmer errors?

Of course   sizeof(x)  could really be meant in the way that
the standard prescribes for interpreting it, so I see little
chance. It would be VERY nice though.

Regards,

Claus

-- 
Claus Fischer <claus.fischer@clausfischer.com>
http://www.clausfischer.com/



More information about the Gcc mailing list