[PATCH] Fix PR35609, spurious "is" used uninitialized warning
Kaveh R. GHAZI
ghazi@caip.rutgers.edu
Wed Mar 26 19:49:00 GMT 2008
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?
Thanks,
--Kaveh
--
Kaveh R. Ghazi ghazi@caip.rutgers.edu
More information about the Gcc-patches
mailing list