This is the mail archive of the gcc-bugs@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]

Bug in the mangler of the new ABI (both 3.0 and 3.1)



>Submitter-Id:	net
>Originator:	Carlo Wood
>Organization:	
>Confidential:	no
>Synopsis:	Bug in the mangler of the new ABI (both 3.0 and 3.1)
>Severity:	critical
>Priority:	high
>Category:	middle-end
>Class:		wrong-code
>Release:	3.0 20010226 (prerelease)
>Environment:
System: Linux ansset 2.4.0-test10 #2 Thu Nov 2 10:05:20 CET 2000 i686 unknown
Architecture: i686

	
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: /usr/src/gcc/gcc-cvs-3.0/configure --prefix=/usr/local/gcc-3.0 --enable-shared --with-gnu-as --with-gnu-ld --enable-languages=c++
>Description:
	The mangler of both 3.0 and 3.1 produces a wrong name for const member functions.
>How-To-Repeat:
Compile the following code snippet:

#include <iostream>
 
// Used helper types.
class return_type { };
class parameters { };
struct scopetype {
  return_type f1(parameters) { }
  return_type f2(parameters) const { }
};
 
// The bug.
void overloaded_function(return_type (scopetype::*foo)(parameters))
{
  std::cout << "Calling: overloaded_function(return_type (scopetype::*foo)(parameters))\n";
}
void overloaded_function(return_type (scopetype::*foo)(parameters) const)
{
  std::cout << "Calling: overloaded_function(return_type (scopetype::*foo)(parameters) const)\n";
}
 
int main(void)
{
  struct scopetype s;
  overloaded_function(&scopetype::f1);
  overloaded_function(&scopetype::f2);
  return 0;
}

With g++-2.95.2 this results in:
~/c++/libcw/src/gcc.bugs>g++-2.95.2 20010301.cc
~/c++/libcw/src/gcc.bugs>a.out
Calling: overloaded_function(return_type (scopetype::*foo)(parameters))
Calling: overloaded_function(return_type (scopetype::*foo)(parameters) const)

With g++-3.0 this results in:
~/c++/libcw/src/gcc.bugs>g++-3.0 20010301.cc
20010301.cc: In function `void overloaded_function(return_type
   (scopetype::*)(parameters) const)':
20010301.cc:17: Internal error #378.
20010301.cc:17: Internal compiler error in pushdecl, at cp/decl.c:4051
Please submit a full bug report, with preprocessed source if appropriate.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.

With g++-3.1 this results in:
~/c++/libcw/src/gcc.bugs>g++-3.1 20010301.cc
20010301.cc: In function `void overloaded_function(return_type
   (scopetype::*)(parameters) const)':
20010301.cc:17: Internal error #378.
20010301.cc:17: Internal compiler error in pushdecl, at cp/decl.c:4052
Please submit a full bug report, with preprocessed source if appropriate.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.

The reason is probably the name mangling (that how I created this code
snippet to begin with, after I found that the mangling was wrong).
The mangled name of 'return_type (scopetype::*foo)(parameters) const' doesn't
include the "const" and is hence equal to the mangled name of
'return_type (scopetype::*foo)(parameters)'.
>Fix:
	


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