https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78589

--- Comment #2 from Martin Jambor <jamborm at gcc dot gnu.org> ---
(In reply to Alexander Monakov from comment #1)
> A similar issue can be seen with IPA cloning.  It's more rare, because it's
> triggered only with warnings that are issued late, after IPA transforms
> (note the extra '.constprop' in the following sample).

I think that the constprop is generally the expected behavior at this
point in time, although it would indeed be nicer if we could produce
an output that would be more user friendly (it is probably possible
that a warning is emitted only for a clone, when we know more about
the context, even in your example the warning is different with
-fno-ipa-cp).

> gcc -S -Wall -O2 t.c
> t.c: In function ‘foo.constprop’:
> t.c:5:13: warning: ‘r’ is used uninitialized in this function
> [-Wuninitialized]
>    return v?v:r;

Note that you use gcc here whereas I filed this bug specifically
against g++.  In fact, if you compile your test-case with g++, you
get:

$ ~/gcc/trunk/inst/bin/g++ -Wall -S -O2 clone.c 
clone.c: In function ‘int foo(int)’:
clone.c:5:14: warning: ‘r’ is used uninitialized in this function
[-Wuninitialized]
   return v?v:r;
              ^

Also, if you remove the static keyword and compile with g++ -O3, you get
two slightly different warnings apparently for the same spot in the
same same function.

This is not to argue that we should not try to convey to the user
better what is going on, I just had a much smaller problem in mind
when filing the PR :-)

Reply via email to