https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98160

            Bug ID: 98160
           Summary: [11 Regression] ICE in default_tree_printer at
                    gcc/tree-diagnostic.c:270 since
                    r11-5732-gdce6c58db87ebf7f
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: marxin at gcc dot gnu.org
                CC: msebor at gcc dot gnu.org
  Target Milestone: ---

Since the revision 523.xalancbmk_r is broken with -O2 -flto.
There's a reduced test-case:

$ cat 1.ii
namespace xercesc_2_7 {
class MemoryManager;
class XMemory {
public:
  void *operator new(unsigned long, MemoryManager *);
  void operator delete(void *, MemoryManager *);
};
class XMLPlatformUtils {
public:
  static MemoryManager *fgMemoryManager;
};
class XMLMutex : public XMemory {
public:
  XMLMutex();
};
void gValidatorMutex() { new (XMLPlatformUtils::fgMemoryManager) XMLMutex; }
} // namespace xercesc_2_7

$ cat 2.ii
namespace xercesc_2_7 {
class MemoryManager;
class XMemory {
  void *operator new(unsigned long, MemoryManager *);
};
class MemoryManager {
public:
  virtual void *allocate();
};
void *XMemory::operator new(unsigned long, MemoryManager *manager) {
  long headerSize(sizeof(MemoryManager));
  void *block = manager->allocate();
  return block + headerSize;
}
} // namespace xercesc_2_7

$ g++ 1.ii 2.ii -flto -O2 -shared
2.ii: In static member function 'static void* xercesc_2_7::XMemory::operator
new(long unsigned int, xercesc_2_7::MemoryManager*)':
2.ii:13:16: warning: pointer of type 'void *' used in arithmetic
[-Wpointer-arith]
   13 |   return block + headerSize;
      |          ~~~~~~^~~~~~~~~~~~
1.ii: In function 'gValidatorMutex':
1.ii:16:66: warning: 'operator delete' called on pointer '_12' with nonzero
offset 8 [-Wfree-nonheap-object]
   16 | void gValidatorMutex() { new (XMLPlatformUtils::fgMemoryManager)
XMLMutex; }
      |                                                                  ^
'
during RTL pass: expand
Segmentation fault
0xcc206f crash_signal
        /home/marxin/Programming/gcc/gcc/toplev.c:327
0xd1c6dd default_tree_printer(pretty_printer*, text_info*, char const*, int,
bool, bool, bool, bool*, char const**)
        /home/marxin/Programming/gcc/gcc/tree-diagnostic.c:270
0xd1c6dd default_tree_printer(pretty_printer*, text_info*, char const*, int,
bool, bool, bool, bool*, char const**)
        /home/marxin/Programming/gcc/gcc/tree-diagnostic.c:247
0x180574c pp_format(pretty_printer*, text_info*)
        /home/marxin/Programming/gcc/gcc/pretty-print.c:1475
0x17e95a6 diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*)
        /home/marxin/Programming/gcc/gcc/diagnostic.c:1216
0x17ec107 diagnostic_impl
        /home/marxin/Programming/gcc/gcc/diagnostic.c:1366
0x17ec107 inform(unsigned int, char const*, ...)
        /home/marxin/Programming/gcc/gcc/diagnostic.c:1445
0x811dc3 warn_dealloc_offset
        /home/marxin/Programming/gcc/gcc/builtins.c:13206
0x82003d maybe_emit_free_warning(tree_node*)
        /home/marxin/Programming/gcc/gcc/builtins.c:13344
0x838ece initialize_argument_information
        /home/marxin/Programming/gcc/gcc/calls.c:2629
0x838ece expand_call(tree_node*, rtx_def*, int)
        /home/marxin/Programming/gcc/gcc/calls.c:4009
0x96bb54 expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
        /home/marxin/Programming/gcc/gcc/expr.c:11252
0x84cb3d expand_expr
        /home/marxin/Programming/gcc/gcc/expr.h:282
0x84cb3d expand_call_stmt
        /home/marxin/Programming/gcc/gcc/cfgexpand.c:2831
0x84cb3d expand_gimple_stmt_1
        /home/marxin/Programming/gcc/gcc/cfgexpand.c:3835
0x84cb3d expand_gimple_stmt
        /home/marxin/Programming/gcc/gcc/cfgexpand.c:3999
0x851ffa expand_gimple_basic_block
        /home/marxin/Programming/gcc/gcc/cfgexpand.c:6043
0x853b66 execute
        /home/marxin/Programming/gcc/gcc/cfgexpand.c:6727
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
lto-wrapper: fatal error: g++ returned 1 exit status
compilation terminated.
/usr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status

Reply via email to