This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
sizeof array-typed function parameter: Warning possible?
- From: Claus Fischer <claus dot fischer at clausfischer dot com>
- To: gcc at gcc dot gnu dot org
- Date: Wed, 13 Aug 2003 18:35:35 +0200
- Subject: sizeof array-typed function parameter: Warning possible?
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/