Bug 10401 - [3.2/3.3/3.4 regression] Seg fault with "-pedantic -Wunreachable-code"
Summary: [3.2/3.3/3.4 regression] Seg fault with "-pedantic -Wunreachable-code"
Status: RESOLVED DUPLICATE of bug 10336
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.2
: P3 normal
Target Milestone: ---
Assignee: Steven Bosscher
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2003-04-14 16:06 UTC by olivier.leclant
Modified: 2004-01-17 04:22 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
try.ii (31.29 KB, text/x-c++)
2003-05-21 15:17 UTC, olivier.leclant
Details

Note You need to log in before you can comment on or make changes to this bug.
Description olivier.leclant 2003-04-14 16:06:00 UTC
/usr/include/c++/3.2/bits/stl_alloc.h: In constructor 
   `std::allocator<_Alloc>::allocator() [with _Tp = int]':
/usr/include/c++/3.2/bits/stl_alloc.h:664:   instantiated from `std::allocator<_Alloc>::allocator() [with _Tp = int]'
try.cc:5:   instantiated from here
/usr/include/c++/3.2/bits/stl_alloc.h:664: internal error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

Release:
g++ (GCC) 3.2.3 20030407 (Debian prerelease)

How-To-Repeat:
g++ -pedantic -Wunreachable-code try.ii
Comment 1 olivier.leclant 2003-04-14 16:06:00 UTC
Fix:
Work-around : don't use -Wunreachable-code :-(
Comment 2 Wolfgang Bangerth 2003-04-14 17:04:22 UTC
Responsible-Changed-From-To: unassigned->jason
Responsible-Changed-Why: Likely associated with a patch that led to this
Comment 3 Wolfgang Bangerth 2003-04-14 17:04:22 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: [Gaby, I add you to the list of listeners to this report,
    since it may be a 3.2 branch regression for
    - C++ standard headers
    - a common combination of flags.]
    
    Confirmed. Here's a redux:
    -----------------
    template <typename T>
    struct X {
        X() throw() {}
    };
    template class X<int>;
    -------------------------
    g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -pedantic -Wunreachable-code -c y.cc
    y.cc: In constructor `X<T>::X() [with T = int]':
    y.cc:3:   instantiated from `X<T>::X() [with T = int]'
    y.cc:5:   instantiated from here
    y.cc:3: internal compiler error: Segmentation fault
    
    It fails with both 3.3 and mainline (3.4). I doesn't fail
    with the lates 3.2.3pre I have on my disk, which is
    2003-03-29, but according to the submitter it also fails
    on this branch. Since the code in question is in a standard
    header and the flags used are a rather usual combination,
    this is a quite severe combination.
    
    On mainline, here's a backtrace:
    #0  never_reached_warning (avoided_insn=0x40180c34, finish=0x40180c34)
        at ../../gcc-3.4-CVS/gcc/jump.c:1916
    #1  0x08189b7c in flow_delete_block_noexpunge (b=0x85d1ae0)
        at ../../gcc-3.4-CVS/gcc/cfgrtl.c:379
    #2  0x08189c57 in flow_delete_block (b=0x85d1ae0)
        at ../../gcc-3.4-CVS/gcc/cfgrtl.c:415
    #3  0x083d01eb in try_optimize_cfg (mode=16)
        at ../../gcc-3.4-CVS/gcc/cfgcleanup.c:1775
    #4  0x083d05bc in cleanup_cfg (mode=16)
        at ../../gcc-3.4-CVS/gcc/cfgcleanup.c:1930
    
    It fails in this code
      /* Back up to the first of any NOTEs preceding avoided_insn; flow passes
         us the head of a block, a NOTE_INSN_BASIC_BLOCK, which often follows
         the line note.  */
      for (insn = PREV_INSN (avoided_insn); ; insn = PREV_INSN (insn))
        if (GET_CODE (insn) != NOTE)
          {
    	insn = NEXT_INSN (insn);
    	break;
          }
    since insn==NULL, which doesn't play nice in the GET_CODE.
    This code was added by Jason in 1.221 here:
    revision 1.221
    date: 2003/04/04 01:21:56;  author: jason;  state: Exp;  lines: +12 -2
            PR c/10175
            * jump.c (never_reached_warning): Revert patch of 2002-11-02.
            Look backwards for a line note.
    
    This patch also appears on the 3.2 branch. Jason, can you
    take a look what happens here?
    
    W.
Comment 4 Giovanni Bajo 2003-04-14 19:21:42 UTC
From: "Giovanni Bajo" <giovannibajo@libero.it>
To: "Gabriel Dos Reis" <gdr@integrable-solutions.net>,
	<gcc-gnats@gcc.gnu.org>,
	<gcc-bugs@gcc.gnu.org>,
	<gcc-prs@gcc.gnu.org>,
	<jason@gcc.gnu.org>,
	<olivier.leclant@netcreek.com>
Cc:  
Subject: Re: c++/10401: [3.3/3.4 regression] Seg fault with "-pedantic -Wunreachable-code"
Date: Mon, 14 Apr 2003 19:21:42 +0200

 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&p
 r=10401
 
 I think it's even worse:
 
 ------------------------
 struct Foo
 {
     Foo() throw()
     {}
 };
 
 Foo f;
 ------------------------
 pr10401.cpp: In constructor `Foo::Foo()':
 pr10401.cpp:3: internal compiler error: Segmentation fault
 Please submit a full bug report,
 
 Confirmed on 3.3 and 3.4, I don't have 3.2.3pre.
 
 Giovanni Bajo
 
Comment 5 Steven Bosscher 2003-04-14 23:59:36 UTC
*** This bug has been marked as a duplicate of 10336 ***