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

            Bug ID: 81765
           Summary: Internal compiler error: Segmentation fault with -O2
                    -fnon-call-exceptions
           Product: gcc
           Version: 6.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: theubik at mail dot ru
  Target Milestone: ---

// begin main.cpp
struct A
{
  virtual void do1() { }
};

struct B
{
  A* m_a;
  B() : m_a(nullptr) {}
  B(A* a) : m_a(a) {}
  ~B() { if (m_a) m_a->do1(); }
  void do2(B& other)
  {
    A* tmp = m_a;
    m_a = other.m_a;
    other.m_a = tmp;
  }
  B& operator=(A* a)
  {
    B(a).do2(*this);
    return *this;
  }
};

int main()
{
  int ar[] = { 0, 1 };
  for (int i = 0; i < 2; ++i)
  {
    int j = ar[i];
    B b;
    b = nullptr;
  }
  return 0;
}
// end main.cpp

$ g++ -S -std=c++11 -O2 -fnon-call-exceptions main.cpp
main.cpp: In function ‘int main()’:
main.cpp:25:5: internal compiler error: Segmentation fault
int main()
    ^~~~
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-6/README.Bugs> for instructions

$ g++ --version
gcc (Debian 6.3.0-18) 6.3.0 20170516
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ uname -a
Linux machine 4.9.0-3-amd64 #1 SMP Debian 4.9.30-2+deb9u2 (2017-06-26) x86_64
GNU/Linux

Reply via email to