sizeof array-typed function parameter: Warning possible?

Andrew Pinski pinskia@physics.uc.edu
Wed Aug 13 20:49:00 GMT 2003


It is already filed as bug 6940.

Thanks,
Andrew Pinski

On Wednesday, Aug 13, 2003, at 12:35 US/Eastern, Claus Fischer wrote:

>
> 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