This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: "Fix" PR C++/9729


PR c++/9729 is a C++ regression -- of sorts.  What happenned is that a
bug in the G++ 3.2 ABI can cause multiple conversion operators to get
the same mangled name.  I introduced an assert for that -- but I
should have really introduced an error message.

So, this patch causes us to issue the error message.

There exist programs that compiled -- to bogus output -- with GCC 3.2
that will now trigger this error.  This isn't really a regression --
it's better to warn the user that their code won't work the way they
expect.

The ABI bug has long since been fixed with -fabi-version=0, but no fix
is possible that preserves the G++ 3.2 ABI.

Tested on i686-pc-linux-gnu, applied on the 3.3 branch and on the
mainline.

-- 
Mark Mitchell                   mark at codesourcery dot com
CodeSourcery, LLC               http://www.codesourcery.com

2003-02-20  Mark Mitchell  <mark at codesourcery dot com>

	PR c++/9729
	* g++.dg/abi/conv1.C: New test.

2003-02-20  Mark Mitchell  <mark at codesourcery dot com>

	PR c++/9729
	* mangle.c (mangle_conv_op_name_for_type): Issue an error message
	when the G++ 3.2 ABI prevents correct compilation.

Index: testsuite/g++.dg/abi/conv1.C
===================================================================
RCS file: testsuite/g++.dg/abi/conv1.C
diff -N testsuite/g++.dg/abi/conv1.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/abi/conv1.C	20 Feb 2003 19:04:10 -0000
***************
*** 0 ****
--- 1,13 ----
+ // { dg-options "-fabi-version=1" }
+ 
+ template<class T1>
+ struct A {
+   typedef typename T1::X X;
+   operator X() const;
+ };
+ 
+ template <class T0, class T1 >
+ struct B {
+   typedef typename T1::X X;
+   operator X() const; // { dg-error "" }
+ };
Index: cp/mangle.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/mangle.c,v
retrieving revision 1.66
diff -c -p -r1.66 mangle.c
*** cp/mangle.c	1 Jan 2003 11:58:57 -0000	1.66
--- cp/mangle.c	20 Feb 2003 19:04:12 -0000
***************
*** 1,5 ****
  /* Name mangling for the 3.0 C++ ABI.
!    Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
     Written by Alex Samuel <sameul at codesourcery dot com>
  
     This file is part of GCC.
--- 1,5 ----
  /* Name mangling for the 3.0 C++ ABI.
!    Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
     Written by Alex Samuel <sameul at codesourcery dot com>
  
     This file is part of GCC.
*************** mangle_conv_op_name_for_type (type)
*** 2644,2652 ****
    free (op_name);
  
    /* It had better be a unique mangling for the type.  */
!   my_friendly_assert (!IDENTIFIER_TYPENAME_P (identifier)
! 		      || same_type_p (type, TREE_TYPE (identifier)),
! 		      20011230);
    
    /* Set bits on the identifier so we know later it's a conversion.  */
    IDENTIFIER_OPNAME_P (identifier) = 1;
--- 2644,2659 ----
    free (op_name);
  
    /* It had better be a unique mangling for the type.  */
!   if (IDENTIFIER_TYPENAME_P (identifier)
!       && !same_type_p (type, TREE_TYPE (identifier)))
!     {
!       /* In G++ 3.2, the name mangling scheme was ambiguous.  In later
! 	 versions of the ABI, this problem has been fixed.  */
!       if (abi_version_at_least (2))
! 	abort ();
!       error ("due to a defect in the G++ 3.2 ABI, G++ has assigned the "
! 	     "same mangled name to two different types");
!     }
    
    /* Set bits on the identifier so we know later it's a conversion.  */
    IDENTIFIER_OPNAME_P (identifier) = 1;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]