[Bug c++/17431] [3.4/4.0 regression] Internal error: Segmentation fault (program cc1plus)

reichelt at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Sun Sep 12 11:28:00 GMT 2004


------- Additional Comments From reichelt at gcc dot gnu dot org  2004-09-12 11:28 -------
Here's a reduced testcase:

=========================
struct A {};

struct B : A
{
  B(int);
  B(B&);
  B(A);
};

void foo(B);

void bar()
{
  foo(0);
}
=========================

The copy ctor B(B&) seems to be responsible for the trouble.
Replacing it by B(const B&) cures the problem.

Upon closer inspection, the code seems to be invalid, since we
really need a copy ctor of the form B(const B&). However, we did not
diagnose this before 3.4.1, and the code compiled without trouble.

Phils regression hunter states
: Search converges between 2004-06-28-3.4 (#11) and 2004-06-29-3.4 (#12).

Btw, adding the missing typename and fixing the copy ctor in the
original testcase with the following patch makes the code compile
with gcc 3.4.1 and later:

=======================================================================
--- CCommand.ii	2004-09-12 13:01:48.000000000 +0200
+++ CCommand.ii	2004-09-12 13:02:05.000000000 +0200
@@ -38769,7 +38769,7 @@ void CMap<TKEY,TVALUE>::writeObject(CObj
 template <class TKEY, class TVALUE>
 void CMap<TKEY,TVALUE>::put (TKEY key, TVALUE value)
 {
- this->insert (std::map<TKEY,TVALUE>::value_type(key, value));
+ this->insert (typename std::map<TKEY,TVALUE>::value_type(key, value));
 }
 # 7 "../../../../common/cpp/ccommand/CMessage.h" 2
 # 1 "../../../../common/cpp/serialization/types/CString.h" 1
@@ -38791,7 +38791,7 @@ class CString : public Serializable, pub
  CString (const char* str);
 
 
- CString (CString& str);
+ CString (const CString& str);
  CString (string str);
 
 
=======================================================================


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|ice-on-valid-code           |ice-on-invalid-code
   Last reconfirmed|0000-00-00 00:00:00         |2004-09-12 11:28:16
               date|                            |
   Target Milestone|3.4.4                       |3.4.3


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



More information about the Gcc-bugs mailing list