public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "eggert at gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/48968] New: incorrect warning about longjmp/vfork clobbering a local (-W -O2, x86-64)
Date: Wed, 11 May 2011 20:04:00 -0000	[thread overview]
Message-ID: <bug-48968-4@http.gcc.gnu.org/bugzilla/> (raw)

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


             reply	other threads:[~2011-05-11 20:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-11 20:04 eggert at gnu dot org [this message]
2011-05-11 20:00 ` [Bug c/48968] " eggert at gnu dot org
2011-05-12 11:07 ` rguenth at gcc dot gnu.org
2011-05-12 13:54 ` schwab@linux-m68k.org
2011-05-12 19:11 ` jakub at gcc dot gnu.org
2011-05-12 20:22 ` eggert at gnu dot org
2012-06-01 20:42 ` eggert at gnu dot org
2012-06-01 21:19 ` eggert at gnu dot org
2014-01-19 18:01 ` mpolacek at gcc dot gnu.org
2014-01-19 18:34 ` eggert at gnu dot org
2014-01-19 20:31 ` mpolacek 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-48968-4@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).