internal compiler error: in type_throw_all_p, at cp/except.c:1307

Bug #1830506 reported by BaiYang
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gcc-4.9 (Ubuntu)
New
Undecided
Unassigned

Bug Description

ubuntu 16.04, gcc 4.9.4 installed from: ppa:ubuntu-toolchain-r/test

When compile a simple test code:
/.../__test.cpp:186:3: internal compiler error: in type_throw_all_p, at cp/except.c:1307
   {}
   ^
Please submit a full bug report,

The full code is here:

/////////////////////////////////// begin of __test.cpp

#include <iostream>
#include <string>
#include <iomanip>
#include <limits.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <map>
#include <math.h>
#include <typeinfo>
#include <deque>
#include <new>
#include <bitset>
#include <typeinfo>
#include <memory>
using namespace std;

template<class _TT>
struct DeletorBase
{
 typedef _TT value_type;
 typedef _TT* pointer;
 typedef const _TT* const_pointer;

 static constexpr bool ShouldThrow(void)
  { return true; }
};

template<class _TT>
struct GuardedDeletor : DeletorBase<_TT>
{
 static constexpr bool ShouldThrow(void)
  { return !std::is_nothrow_destructible<_TT>::value; }

 static inline void del(typename DeletorBase<_TT>::pointer p)
 {
  if (ShouldThrow()) // Compiling time optimize
  {
   try
   {
    delete p;
   }
   catch (...)
   {
    operator delete(p);
    throw;
   }
  }
  else
  {
   delete p;
  }
 }
};

template< class _TT, class _DEL = GuardedDeletor< _TT > >
class CMyHandle
{
public:
 CMyHandle(_TT* ptr)
  : m_ptr(ptr)
  {}
 ~CMyHandle() noexcept(!_DEL::ShouldThrow())
  { _DEL::del(m_ptr); }

private:
 _TT* m_ptr;
};

class CMyClass
{
public:
 CMyClass(int n = 0)
  : m_thTest(new std::string)
  {}

 ~CMyClass()
  {}

    typedef CMyHandle< std::string > THCLI;
    THCLI m_thTest;
};

int
main(int argc, char* argv[])
{
 return 0;
}

/////////////////////////////////// end of __test.cpp

The compile command line is:

g++-4.9 -Wall -fexceptions -fvisibility=hidden -march=athlon64 -O3 -w -std=c++11 --param inline-unit-growth=200 -msse2 -I/root/develop-lib/utilitis/include -I/root/develop-lib/crypto/include -I/root/develop-lib/DM/sqlite_cpp/include -I/root/develop-lib/DM/report/include -I/root/develop-lib/DM/odbc_cpp/include -I/root/develop-lib/DM/apidbc/include -c /root/tmp/__tests/__test/__test.cpp -o linux_x64/obj/__test.o

Revision history for this message
BaiYang (asbai) wrote :
Revision history for this message
BaiYang (asbai) wrote :

If I change `~MyClass()` to `~MyClass() noexcept` than everything is ok.

Revision history for this message
BaiYang (asbai) wrote :

This seems to be a known and fixed issue: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67870

Can this fix migrate back to the 4.9 branch?

Thanks

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.