public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/6828: g++3 makes wrong mangled name for template cast operator
@ 2002-07-29  7:06 Kriang Lerdsuwanakij
  0 siblings, 0 replies; 3+ messages in thread
From: Kriang Lerdsuwanakij @ 2002-07-29  7:06 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/6828; it has been noted by GNATS.

From: Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
To: Grigory_Zagorodnev@vniief.ims.intel.com, gcc-gnats@gcc.gnu.org,
        gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org
Cc:  
Subject: Re: c++/6828: g++3 makes wrong mangled name for template cast operator
Date: Mon, 29 Jul 2002 21:05:03 +0700

 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6828
 
 The reason the fix didn't get into GCC 3.1.1 is that the
 changed name mangling break ABI compatibility.  But the fix
 will appear in the soon to be released GCC 3.2.  GCC 3.2 is
 GCC 3.1.1 with extra bug fixes that provide no backward
 binary compatibility.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: c++/6828: g++3 makes wrong mangled name for template cast operator
@ 2002-06-24  8:03 lerdsuwa
  0 siblings, 0 replies; 3+ messages in thread
From: lerdsuwa @ 2002-06-24  8:03 UTC (permalink / raw)
  To: Grigory_Zagorodnev, gcc-bugs, gcc-prs, nobody

Synopsis: g++3 makes wrong mangled name for template cast operator

State-Changed-From-To: open->closed
State-Changed-By: lerdsuwa
State-Changed-When: Mon Jun 24 07:59:46 2002
State-Changed-Why:
    Fixed in the main trunk.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6828


^ permalink raw reply	[flat|nested] 3+ messages in thread

* c++/6828: g++3 makes wrong mangled name for template cast operator
@ 2002-05-27  3:26 Grigory_Zagorodnev
  0 siblings, 0 replies; 3+ messages in thread
From: Grigory_Zagorodnev @ 2002-05-27  3:26 UTC (permalink / raw)
  To: gcc-gnats


>Number:         6828
>Category:       c++
>Synopsis:       g++3 makes wrong mangled name for template cast operator
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon May 27 03:16:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Grigory Zagorodnev
>Release:        3.1
>Organization:
>Environment:
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ./configure
>Description:
1. The issue

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

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 ();
--------------------------------------------------------------

2. 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.


3. 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:
	_ZN1Ccv1AIS0_EEv
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:
	_ZN1CcvT_I1AEEv
where part (a) depends from type specified in part (b) so it reference it as <template-param>.


4. Decoder
It's true that the 'c++filt' is not able to decode given names. But decoder is not guilty.
The root of the problem is the mangling grammer.

>How-To-Repeat:
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.
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-07-29 14:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-29  7:06 c++/6828: g++3 makes wrong mangled name for template cast operator Kriang Lerdsuwanakij
  -- strict thread matches above, loose matches on Subject: below --
2002-06-24  8:03 lerdsuwa
2002-05-27  3:26 Grigory_Zagorodnev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).