Bug 65035 - g++3 makes wrong mangled name for template cast operator
g++3 makes wrong mangled name for template cast operator
Product: Red Hat Linux
Classification: Retired
Component: gcc3 (Show other bugs)
All Linux
medium Severity high
: ---
: ---
Assigned To: Jakub Jelinek
Depends On:
  Show dependency treegraph
Reported: 2002-05-16 09:39 EDT by Grigory Zagorodnev
Modified: 2016-10-03 16:11 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2002-12-15 15:22:32 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

External Trackers
Tracker ID Priority Status Summary Last Updated
oVirt gerrit 65035 master MERGED resourcemanager: Use new module api 2016-10-03 16:11 EDT

  None (edit)
Description Grigory Zagorodnev 2002-05-16 09:39:27 EDT
From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0; NetCaptor 

Description of problem:
In the given testcase, for operator "template <class T> C::operator T ()" with 
T = {int}, g++3 compiler produces the following mangled name:

but it's expected to have mangled name "_ZN1CcvT_IiEEv" here.

--- testcase (fail.cpp) -------------------------------------
struct C {
  template <class T>
  operator T ();

template <class T>
C::operator T () { return 0; }

template C::operator int ();

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. compile testcase 
    g++3 -c fail.cpp

2. get list of produced mangled names in the object file
    nm fail.o | grep _Z

3. You will see
**** T _ZN1CcviIiEEv
Which is wrong.


Additional info:
Comment 1 Jakub Jelinek 2002-05-16 10:46:34 EDT
Your expected mangling is not even accepted by c++filt as valid.
Can you please explain why do you think it is mangled improperly?
Comment 2 Grigory Zagorodnev 2002-05-20 02:14:35 EDT
1. Clarify the issue
Unfortunately, the mangling grammer given in the ABI is ambiguous in this area, 
so we need to think more about it.

First of all, let's decompose the mangled name taking GCC's encoding (it does 
not matter which one to take).
We are interesting in the following parts of '_ZN1CcviIiEEv' mangled name:
	a) cvi		# <operator-name> ::= cv <type>
	b) IiE		# <template-args> ::= I <type>+ E

In both parts, value of <type> used to be the same. And it is really the same 8-
But, only one question is there: 
	Which part should be encoded/decoded first? (the hen or the egg)

As I can see, part a) depends on type value of b). 
So the <type> in the a should be a reference to template argument from b.

2. Clarify compiler behaviour
Let's change our example to make the behaviour more clean and see what exactly 
compilers are doing. 
According to the ABI, built-in types are not substituted, so it's better to 
change built-in type 'int' to some class 'A'.

Now we that g++3 encodes operator as:
i.e. type 1A in the part (a) of mangled name becomes major one, and part (b) 
reference it by <substitution>

While the correct code is:
where part (a) depends from type specified in part (b) so it reference it as 

3. Decoder
Yes, c++filt is not able to decode given names. But decoder is not guilty.
The root of the problem is the mangling grammer.
Comment 3 Alan Cox 2002-12-15 15:22:32 EST
Correct result produced by 8.0 g++ 3.2

Note You need to log in before you can comment on or make changes to this bug.