Bug 53011 - [4.8 Regression] ice in verify_loop_structure: bad sizes
Summary: [4.8 Regression] ice in verify_loop_structure: bad sizes
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: 4.8.0
Assignee: Richard Biener
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-04-16 18:33 UTC by David Binderman
Modified: 2012-04-17 13:43 UTC (History)
1 user (show)

See Also:
Host:
Target: x86_64-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed: 2012-04-17 00:00:00


Attachments
C++ source code (99.74 KB, text/x-c++src)
2012-04-16 18:33 UTC, David Binderman
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Binderman 2012-04-16 18:33:13 UTC
Created attachment 27171 [details]
C++ source code

I just tried to compile the package libwvstreams-4.6.1-4
on gcc-4.8 trunk dated 20120415 on an AMD x86_64 box.

The compiler said

linuxstreams/wvinterface.cc: In member function 'int WvInterface::delroute(const WvIPNet&, const WvIPAddr&, int, WvStringParm)':
linuxstreams/wvinterface.cc:479:5: error: size of loop 2 should be 0, not 1
 int WvInterface::delroute(const WvIPNet &dest, const WvIPAddr &gw,
     ^
linuxstreams/wvinterface.cc:479:5: error: bb 89 do not belong to loop 2
 int WvInterface::delroute(const WvIPNet &dest, const WvIPAddr &gw,
     ^
linuxstreams/wvinterface.cc:479:5: error: loop 2's header does not belong directly to it
 int WvInterface::delroute(const WvIPNet &dest, const WvIPAddr &gw,
     ^
linuxstreams/wvinterface.cc:479:5: internal compiler error: in verify_loop_structure, at cfgloop.c:1567
 int WvInterface::delroute(const WvIPNet &dest, const WvIPAddr &gw,
     ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

Preprocessed source code attached. Flag -O2 required.
Comment 1 Markus Trippelsdorf 2012-04-16 19:35:42 UTC
Somewhat reduced:

 % cat test.ii
extern "C" class WvFastString;
typedef WvFastString& WvStringParm;
struct WvFastString {
  ~WvFastString();
  operator char* () {}
};
class WvString : WvFastString {};
class WvAddr {};
class WvIPAddr : WvAddr {};
struct WvIPNet : WvIPAddr {
  bool is_default() {}
};
template<class T, bool> struct WvTraits_Helper {
  static void release(T *obj) {
    delete obj;
  }
};
template<class From> struct WvTraits {
  static void release(From *obj) {
    WvTraits_Helper<From, 0>::release(obj);
  }
};
struct WvLink {
  void   *data;
  WvLink *next;
  bool    autofree;
  WvLink(bool, int) : autofree() {}
  bool get_autofree() {}

  void unlink() {
    delete this;
  }
};
struct WvListBase {
  WvLink head, *tail;
  WvListBase() : head(0, 0) {}
};
template<class T> struct WvList : WvListBase {
  ~WvList() {
    zap();
  }

  void zap(bool destroy = 1) {
    while (head.next) unlink_after(&head, destroy);
  }

  void unlink_after(WvLink *after, bool destroy) {
    WvLink *next = 0;
    T *obj       = (destroy && next->get_autofree()) ? 
                   static_cast<T*>(next->data) : 0;

    if (tail) tail = after;
    next->unlink();
    WvTraits<T>::release(obj);
  }
};
typedef WvList<WvString>WvStringListBase;
class WvStringList : WvStringListBase {};
class WvSubProc {
  WvStringList last_args, env;
};
void addroute(WvIPNet& dest, WvStringParm table) {
  if (dest.is_default() || (table != "default")) WvSubProc checkProc;
}

 % g++ -c -O1 test.ii
test.ii: In function ‘void addroute(WvIPNet&, WvStringParm)’:
test.ii:64:1: internal compiler error: Segmentation fault
Comment 2 Markus Trippelsdorf 2012-04-16 19:59:38 UTC
create_preheader (loop=0x7ffff7452440, flags=<optimized out>) at /home/markus/gcc/gcc/cfgloopmanip.c:1391
1391      latch_edge_was_fallthru = (mfb_kj_edge->flags & EDGE_FALLTHRU) != 0;
(gdb) bt
#0  create_preheader (loop=0x7ffff7452440, flags=<optimized out>) at /home/markus/gcc/gcc/cfgloopmanip.c:1391
#1  0x0000000000607838 in create_preheaders (flags=1) at /home/markus/gcc/gcc/cfgloopmanip.c:1443
#2  0x000000000074e417 in loop_optimizer_init (flags=flags@entry=7) at /home/markus/gcc/gcc/loop-init.c:89
#3  0x000000000074e4ef in rtl_loop_init () at /home/markus/gcc/gcc/loop-init.c:210
#4  0x000000000078dec8 in execute_one_pass (pass=pass@entry=0x1074880) at /home/markus/gcc/gcc/passes.c:2176
#5  0x000000000078e225 in execute_pass_list (pass=0x1074880) at /home/markus/gcc/gcc/passes.c:2231
#6  0x000000000078e237 in execute_pass_list (pass=0x10748e0) at /home/markus/gcc/gcc/passes.c:2232
#7  0x000000000078e237 in execute_pass_list (pass=0x1074cc0) at /home/markus/gcc/gcc/passes.c:2232
#8  0x0000000000612c69 in tree_rest_of_compilation (node=<error reading variable: Unhandled dwarf expression opcode 0xfa>)
    at /home/markus/gcc/gcc/cgraphunit.c:1898
#9  0x00000000006157d2 in cgraph_expand_function (node=0x7ffff7412720) at /home/markus/gcc/gcc/cgraphunit.c:1968
#10 0x0000000000616c28 in cgraph_expand_all_functions () at /home/markus/gcc/gcc/cgraphunit.c:2033
#11 cgraph_optimize () at /home/markus/gcc/gcc/cgraphunit.c:2724
#12 0x000000000061749a in cgraph_finalize_compilation_unit () at /home/markus/gcc/gcc/cgraphunit.c:2809
#13 0x00000000004f1b2f in cp_write_global_declarations () at /home/markus/gcc/gcc/cp/decl2.c:4072
#14 0x000000000081fbd8 in compile_file () at /home/markus/gcc/gcc/toplev.c:572
#15 do_compile () at /home/markus/gcc/gcc/toplev.c:1938
#16 toplev_main (argc=13, argv=0x7fffffffe438) at /home/markus/gcc/gcc/toplev.c:2014
#17 0x00007ffff7893675 in __libc_start_main (main=0x5c1b40 <main>, argc=13, ubp_av=0x7fffffffe438, init=<optimized out>, fini=<optimized out>, 
    rtld_fini=<optimized out>, stack_end=0x7fffffffe428) at libc-start.c:225
#18 0x0000000000492369 in _start () at ../sysdeps/x86_64/start.S:116
Comment 3 Richard Biener 2012-04-17 08:50:30 UTC
Sigh.  Mine.
Comment 4 Richard Biener 2012-04-17 11:00:36 UTC
EH cleanup turns a loop nest of two into a single loop with multiple latches
by forwarding through an empty EH region.
Comment 5 Richard Biener 2012-04-17 13:42:56 UTC
Author: rguenth
Date: Tue Apr 17 13:42:48 2012
New Revision: 186529

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186529
Log:
2012-04-17  Richard Guenther  <rguenther@suse.de>

	PR middle-end/53011
	* tree-eh.c (cleanup_empty_eh_merge_phis): Properly discard
	loops when redirecting an entry or latch edge.

	* g++.dg/torture/pr53011.C: New testcase.

Added:
    trunk/gcc/testsuite/g++.dg/torture/pr53011.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-eh.c
Comment 6 Richard Biener 2012-04-17 13:43:36 UTC
Fixed.