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

            Bug ID: 89285
           Summary: ICE after casting the this pointer in the constructor
                    in C++17 mode
           Product: gcc
           Version: 8.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: guus at debian dot org
  Target Milestone: ---

Created attachment 45656
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45656&action=edit
Minimal reproducer code

While developing some code that links nested struct variables together in a
linked list at compile time, I got an ICE when I modified my code to, instead
of
storing pointers in the linked list, stored relative offsets. It seems that the
ICE was triggered due to doing a reinterpret_cast<char *>(this) inside a
constructor, although I might be wrong about that.

GCC version: gcc (Debian 8.2.0-20) 8.2.0
System type: Debian GNU/Linux unstable on an AMD64 machine

> g++ -std=c++17 -c reproducer.cc
during RTL pass: expand
reproducer.cc: In function ‘void __static_initialization_and_destruction_0(int,
int)’:
reproducer.cc:11:43: internal compiler error: in expand_expr_real_1, at
expr.c:10043
   *child = reinterpret_cast<char *>(this) - reinterpret_cast<char *>(child);
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0x7f4478edc09a __libc_start_main
        ../csu/libc-start.c:308

Reply via email to