[PATCH] Fix PR35609, spurious "is" used uninitialized warning
Richard Guenther
richard.guenther@gmail.com
Wed Mar 26 20:19:00 GMT 2008
On Wed, Mar 26, 2008 at 7:43 PM, Kaveh R. GHAZI <ghazi@caip.rutgers.edu> wrote:
> On Tue, 18 Mar 2008, Richard Guenther wrote:
>
> > Index: testsuite/gcc.dg/uninit-16.c
> > ===================================================================
> > *** testsuite/gcc.dg/uninit-16.c (revision 0)
> > --- testsuite/gcc.dg/uninit-16.c (revision 0)
> > ***************
> > *** 0 ****
> > --- 1,22 ----
> > + /* { dg-do compile } */
> > + /* { dg-options "-O2 -Wuninitialized" } */
> > +
> > + int foo, bar;
> > +
> > + void decode_reloc(int reloc, int *is_alt)
> > + {
> > + if (reloc >= 20)
> > + *is_alt = 1;
> > + else if (reloc >= 10)
> > + *is_alt = 0;
> > + }
> > +
> > + void testfunc()
> > + {
> > + int alt_reloc;
> > +
> > + decode_reloc(foo, &alt_reloc);
> > +
> > + if (alt_reloc) /* { dg-warning "maybe used uninitialized" } */
> > + bar = 42;
> > + }
>
> Hi Richard,
>
> This testcase fails with -fpic or -fPIC on mainline and 4.3.x:
> http://gcc.gnu.org/ml/gcc-testresults/2008-03/msg02042.html
>
> It is fixed by either making decode_reloc static, or compiling with -fpie,
> so that the function binds locally. Which do you prefer?
Make it static.
Richard.
More information about the Gcc-patches
mailing list