public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rbd at debian dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/58377] spurious "may be unused" warning with -Og
Date: Tue, 10 Sep 2013 10:31:00 -0000	[thread overview]
Message-ID: <bug-58377-4-7i7pzjadKP@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-58377-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58377

--- Comment #2 from Roland Dreier <rbd at debian dot org> ---
arg, I really apologize.  I copied and pasted from the wrong window and ended
up with a test case that does NOT reproduce the issue, even on my system.  Here
is one I triple checked does fail (and everything is copied from one window, so
the code is definitely what I built):

$ cat x.cpp
// gcc -Og -Wall -Werror -c x.cpp

int * pop ();

struct A
{
    void * tasks[0];
};

int pop_first_bucket;

int * my_pop (struct A * t)
{
    int * out;

    do {
        if (t->tasks[0] && (out = pop()))
            return out;
    } while (pop_first_bucket);
    return 0;
}

$ gcc -v -Og -Wall -Werror -c x.cpp

Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro
4.8.1-10ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs
--enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.8 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls
--with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin
--with-system-zlib --disable-browser-plugin --enable-java-awt=gtk
--enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre
--enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686
--with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 4.8.1 (Ubuntu/Linaro 4.8.1-10ubuntu1) 
COLLECT_GCC_OPTIONS='-v' '-Og' '-Wall' '-Werror' '-c' '-E' '-mtune=generic'
'-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/4.8/cc1plus -E -quiet -v -imultiarch
x86_64-linux-gnu -D_GNU_SOURCE x.cpp -mtune=generic -march=x86-64 -Wall -Werror
-Og -fstack-protector -Wformat -Wformat-security
ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/4.8"
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/4.8
 /usr/include/x86_64-linux-gnu/c++/4.8
 /usr/include/c++/4.8/backward
 /usr/lib/gcc/x86_64-linux-gnu/4.8/include
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-Og' '-Wall' '-Werror' '-c' '-E' '-mtune=generic'
'-march=x86-64'
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro
4.8.1-10ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs
--enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.8 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls
--with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin
--with-system-zlib --disable-browser-plugin --enable-java-awt=gtk
--enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre
--enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686
--with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 4.8.1 (Ubuntu/Linaro 4.8.1-10ubuntu1) 
COLLECT_GCC_OPTIONS='-v' '-Og' '-Wall' '-Werror' '-c' '-o'
'/home/roland/.ccache/0/5/a073b86e9bd44947a6de1615bfe6ad-3402.o.tmp.roland-t410s.19701'
'-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/4.8/cc1plus -fpreprocessed
/home/roland/.ccache/tmp/x.tmp.roland-t410s.19701.ii -quiet -dumpbase
x.tmp.roland-t410s.19701.ii -mtune=generic -march=x86-64 -auxbase-strip
/home/roland/.ccache/0/5/a073b86e9bd44947a6de1615bfe6ad-3402.o.tmp.roland-t410s.19701
-Og -Wall -Werror -version -fstack-protector -Wformat -Wformat-security -o
/tmp/cce01AiI.s
GNU C++ (Ubuntu/Linaro 4.8.1-10ubuntu1) version 4.8.1 (x86_64-linux-gnu)
    compiled by GNU C version 4.8.1, GMP version 5.1.2, MPFR version 3.1.1-p2,
MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C++ (Ubuntu/Linaro 4.8.1-10ubuntu1) version 4.8.1 (x86_64-linux-gnu)
    compiled by GNU C version 4.8.1, GMP version 5.1.2, MPFR version 3.1.1-p2,
MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: bbda97c7f6a737ad1364ffd9676a3180
x.cpp: In function ‘int* my_pop(A*)’:
x.cpp:14:11: error: ‘out’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]
     int * out;
           ^
cc1plus: all warnings being treated as errors



Interestingly enough, although as you suggested, I converted the test case to
be valid as C, it does not warn when compiled as Cg:

$ cp x.cpp x.c
$ gcc -Og -Wall -Werror -c x.c
$ gcc -std=c99 -Og -Wall -Werror -c x.c
$ gcc -std=c11 -Og -Wall -Werror -c x.c

all succeed with no warnings...


Furthermore, my previous experiments (which led to my mistake in opening this
report), shows that the following change from one if with conditions combined
with && to nested ifs builds fine with -Og as well:

int * pop ();

struct A
{
    void * tasks[0];
};

int pop_first_bucket;

int * my_pop (struct A * t)
{
    int * out;

    do {
        if (t->tasks[0])
            if ((out = pop()))
                return out;
    } while (pop_first_bucket);
    return 0;
}
>From gcc-bugs-return-429440-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Sep 10 10:32:42 2013
Return-Path: <gcc-bugs-return-429440-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 2121 invoked by alias); 10 Sep 2013 10:32:42 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 2084 invoked by uid 48); 10 Sep 2013 10:32:40 -0000
From: "ktietz at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/38614] ICE at simplify-rtx.c:4956
Date: Tue, 10 Sep 2013 10:32:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: rtl-optimization
X-Bugzilla-Version: 4.4.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: ktietz at gcc dot gnu.org
X-Bugzilla-Status: RESOLVED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status cc resolution
Message-ID: <bug-38614-4-OgzZvTS2pj@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-38614-4@http.gcc.gnu.org/bugzilla/>
References: <bug-38614-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-09/txt/msg00680.txt.bz2
Content-length: 632

http://gcc.gnu.org/bugzilla/show_bug.cgi?id8614

Kai Tietz <ktietz at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |ktietz at gcc dot gnu.org
         Resolution|---                         |WONTFIX

--- Comment #4 from Kai Tietz <ktietz at gcc dot gnu.org> ---
If this issue occurs with more recent gcc-version, please open an new bug.  gcc
4.4 is no longer maintained (same as gcc 4.5).
So closing this bug


  parent reply	other threads:[~2013-09-10 10:31 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-10  9:35 [Bug c++/58377] New: " rbd at debian dot org
2013-09-10 10:02 ` [Bug c++/58377] " paolo.carlini at oracle dot com
2013-09-10 10:31 ` rbd at debian dot org [this message]
2013-09-10 10:40 ` rbd at debian dot org
2013-09-10 11:40 ` paolo.carlini at oracle dot com
2013-09-10 12:03 ` rguenth at gcc dot gnu.org
2013-09-10 15:57 ` [Bug c++/58377] spurious "may be used uninitialized" " davidxl at google dot com
2013-09-10 19:46 ` nvachhar at google dot com
2013-09-10 20:14 ` davidxl at google dot com
2013-09-10 20:23 ` davidxl at google dot com
2013-09-10 23:08 ` davidxl at google dot com
2013-09-11  8:25 ` rguenth at gcc dot gnu.org
2013-09-11 12:20 ` rguenth at gcc dot gnu.org
2013-09-11 12:23 ` rguenth at gcc dot gnu.org
2013-09-11 12:23 ` rguenth at gcc dot gnu.org
2013-09-12 13:21 ` rguenth at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-58377-4-7i7pzjadKP@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).