[Bug middle-end/10138] warn for uninitialized arrays passed as const* arguments

manu at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Mon Aug 20 15:03:00 GMT 2007



------- Comment #12 from manu at gcc dot gnu dot org  2007-08-20 15:03 -------
(In reply to comment #11)
> (In reply to comment #10)
> > I now think that Andrew is right and that PR33086 and this one are INVALID.
> > 'const' does not mean read-only in C++ at all, and much less in C. atoi(const
> > char *) could always initialize buf[].
> 
> Uh, no, it can't. If it did (by casting away the 'const' from its argument
> and then writing into the array), this would lead to a segfault:
> -------------
> const char a[3] = "10";
> int main () {
>   return atoi (a);
> }
> -------------

This testcase has nothing to do with uninitialized variables. If the variable
is 'const' already, then there will never be a warning. Will it produce
segmentation fault for a local automatic uninitialized pointer?


-- 


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



More information about the Gcc-bugs mailing list