From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9344 invoked by alias); 11 May 2011 20:03:37 -0000 Received: (qmail 9326 invoked by uid 22791); 11 May 2011 20:03:35 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_GJ X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 11 May 2011 20:03:22 +0000 From: "eggert at gnu dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/48968] New: incorrect warning about longjmp/vfork clobbering a local (-W -O2, x86-64) X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: eggert at gnu dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Wed, 11 May 2011 20:04:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-05/txt/msg00962.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48968 Summary: incorrect warning about longjmp/vfork clobbering a local (-W -O2, x86-64) Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned@gcc.gnu.org ReportedBy: eggert@gnu.org The attached program u.i, derived from the Emacs trunk, has code of the following form: Lisp_Object XXXevent, tem; if (idx < 0) { XXXevent = Qnil; } else { Lisp_Object _l; _l.s.val = idx; _l.s.type = Lisp_Int; XXXevent = _l; } if ((((enum Lisp_Type) ((XXXevent)).u.type)) == Lisp_Int) { ... } These are the only defs and uses of XXXevent, which is a local variable of union type. When compiled with -W -O2 on x86-64, GCC 4.6.0 complains: error: variable 'XXXevent' might be clobbered by 'longjmp' or 'vfork' But no longjmp or vfork is possible between the time that XXXevent is set, and the time that it is used. I worry that this bogus warning is a symptom of deeper problems in GCC 4.6.0's optimizer. Here is the full output of: gcc -v -save-temps -S -W -Wno-missing-field-initializers -Wno-sign-compare -Werror -O2 u.i Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/local_cs/linux/gcc-4.6.0/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.6.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../gcc-4.6.0/configure --prefix=/usr/local/cs/gcc-4.6.0 --with-gmp-include=/usr/local/cs/include --disable-nls --with-stage1-ldflags='-L/usr/local/cs/lib64 -Xlinker -rpath=/usr/local/cs/lib64' --with-boot-ldflags='-L/usr/local/cs/lib64 -Xlinker -rpath=/usr/local/cs/lib64' LDFLAGS='-L/usr/local/cs/lib64 -Xlinker -rpath=/usr/local/cs/lib64' Thread model: posix gcc version 4.6.0 (GCC) COLLECT_GCC_OPTIONS='-v' '-save-temps' '-S' '-Wextra' '-Wno-missing-field-initializers' '-Wno-sign-compare' '-Werror' '-O2' '-mtune=generic' '-march=x86-64' /usr/local_cs/linux/gcc-4.6.0/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.6.0/cc1 -fpreprocessed u.i -quiet -dumpbase u.i -mtune=generic -march=x86-64 -auxbase u -O2 -Wextra -Wno-missing-field-initializers -Wno-sign-compare -Werror -version -o u.s GNU C (GCC) version 4.6.0 (x86_64-unknown-linux-gnu) compiled by GNU C version 4.6.0, GMP version 5.0.2, MPFR version 3.0.1-p4, MPC version 0.9 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 GNU C (GCC) version 4.6.0 (x86_64-unknown-linux-gnu) compiled by GNU C version 4.6.0, GMP version 5.0.2, MPFR version 3.0.1-p4, MPC version 0.9 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 48a4f3d76c3a714a5f5622b4f42440c5 u.i: In function 'read_char': u.i:60167:20: error: variable 'XXXevent' might be clobbered by 'longjmp' or 'vfork' [-Werror=clobbered] cc1: all warnings being treated as errors