This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/10138] warn for uninitialized arrays passed as const* arguments
- From: "bangerth at dealii dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 20 Aug 2007 16:58:47 -0000
- Subject: [Bug middle-end/10138] warn for uninitialized arrays passed as const* arguments
- References: <bug-10138-1038@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #19 from bangerth at dealii dot org 2007-08-20 16:58 -------
(In reply to comment #18)
> When I say "constant are not propagated" I mean "the constant value of a
> variable" such as:
>
> int i=0;
> use(&i);
> foo(i);
>
> Here, GCC does not propagate the value of i to do foo(0). Remove the call to
> use and then it will.
What if you had "const int i=0"? As I said before, use() may do a const-cast
to get rid of the constness of its argument, but the result is only
well-defined
if the object pointed to is actually non-const. That is the case here, so use()
may do exactly this and clobber 'i'. On the other hand, if 'i' was const, then
the result of any const-cast use() may do on its argument are undefined, and
it would seem legitimate to propagate the initial value of 'i' into the call
to foo().
W.
I think that in
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10138