The following code crashes the compiler with this message:
> g++ gccbug.cpp
gccbug.cpp: In destructor 'VEXPR<T>::~VEXPR() [with T = VECTOR_PAIR]':
gccbug.cpp:32: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.


struct VECTOR {};

struct VECTOR_PAIR
{
   VECTOR_PAIR(VECTOR& v1, VECTOR& v2) : first(v1), second(v2) {}

   VECTOR& first;
   VECTOR& second;
};


template <class T>
struct VEXPR
{
    VEXPR(T& leaf) : obj(leaf) {}
   ~VEXPR() {}

   T& obj;
};


VEXPR<VECTOR_PAIR> operator,(VEXPR<VECTOR>& v1, VEXPR<VECTOR>& v2)
{
   VECTOR_PAIR* vp = new VECTOR_PAIR(v1.obj, v2.obj); 
   return VEXPR<VECTOR_PAIR>(*vp); 
}

template <>
VEXPR<VECTOR_PAIR>::~VEXPR<VECTOR_PAIR>()
{
   VECTOR_PAIR *vp = &obj;
   delete vp;
}


-- 
           Summary: compiler segfaults in specialization of template
                    destructor
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: adavis at ti dot com
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44170

Reply via email to