2013/4/15 Jeff Law <l...@redhat.com>: > On 04/13/2013 07:17 PM, Chung-Ju Wu wrote: >> >> Hi, >> >> I noticed there is an uninitialized variable warning >> when compiling tree-ssa-loop-ivcanon.c file. >> >> Attached patch is a slight modification to avoid the warning >> and a plaintext ChangeLog is as below. >> >> Is it OK for trunk? >> >> >> 2013-04-14 Chung-Ju Wu <jasonw...@gmail.com> >> >> * tree-ssa-loop-ivcanon.c (try_unroll_loop_completely): Avoid >> -Wuninitialized warning. > > If this is a false positive (and I think it is from a very quick scan of the > code), can you mark the initialization as such? > > /* Avoid false positive -Wuninitialized warning. */ > > Ideally this will become standard practice. > > jeff
You are right. After doing survey on http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings and reading related discussion thread, I realized it is a complicated detection and this is a false positive case. I was using gcc-4.6.3, which is provided by Ubuntu 12.04, and the warning is displayed during the compilation process. As I tried to build another native gcc by myself with current main trunk and used it to compile tree-ssa-loop-ivcanon.c again, there is no such warning at all. (See attachment for my console output.) So I am wondering if my patch is still valuable since such false positive warning is already fixed on trunk. Or do you think it is still good having the comment in the patch and then OK to commit it? :) Best regards, jasonwucj
[jasonwucj@sw-compiler]$ g++ --version g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3 Copyright (C) 2011 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. [jasonwucj@sw-compiler]$ g++ tree-ssa-loop-ivcanon.ii -S -O2 -Wall /home/jasonwucj/tmp/gcc-svn-trunk/gcc/tree-ssa-loop-ivcanon.c: In function ¡¥bool canonicalize_loop_induction_variables(loop*, bool, unroll_level, bool)¡¦: /home/jasonwucj/tmp/gcc-svn-trunk/gcc/tree-ssa-loop-ivcanon.c:866:46: warning: ¡¥n_unroll¡¦ may be used uninitialized in this function [-Wuninitialized] /home/jasonwucj/tmp/gcc-svn-trunk/gcc/tree-ssa-loop-ivcanon.c:655:17: note: ¡¥n_unroll¡¦ was declared here [jasonwucj@sw-compiler]$ toolchain/bin/g++ --version g++ (20130416) 4.9.0 20130415 (experimental) Copyright (C) 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. [jasonwucj@sw-compiler]$ toolchain/bin/g++ tree-ssa-loop-ivcanon.ii -S -O2 -Wall [jasonwucj@sw-compiler]$