public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/20123] New: mangled name of typeid doesn't encode cv-qualifer.
@ 2005-02-21 23:12 yanliu at ca dot ibm dot com
  2005-02-21 23:15 ` [Bug c++/20123] " pinskia at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: yanliu at ca dot ibm dot com @ 2005-02-21 23:12 UTC (permalink / raw)
  To: gcc-bugs

Here is a testcase:
#include <typeinfo>
int const volatile v5[10] = {0};
int
main (int argc, char **argv) {
  const std::type_info& t = typeid (::v5);
}

According to Itanium C++ ABI, the mangled name of typeid(::v5) should follow 
the following grammer rules:
 <mangled-name> ::= _Z <encoding>
    <encoding> 	::= <special-name>
       <special-name> ::= TI <type>	# typeinfo structure
          <type> ::= <array-type>
             <array-type> ::= A <positive dimension number> _ <element type>

To my understanding, the element type follows the <type> rule and is used to 
encode the type of variable v5[10]:
                <type> ::= <CV-qualifiers> <type>
                   <CV-qualifiers> ::= [r] [V] [K] # restrict (C99), volatile, 
const


So the mangled name should be: __ZTIA10_VKi. But using gcc 4.0 compiler, I am 
getting "__ZTIA10_i" mangled name instead. 

Please verify the problem, thanks.

-- 
           Summary: mangled name of typeid doesn't encode cv-qualifer.
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: yanliu at ca dot ibm dot com
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug c++/20123] mangled name of typeid doesn't encode cv-qualifer.
  2005-02-21 23:12 [Bug c++/20123] New: mangled name of typeid doesn't encode cv-qualifer yanliu at ca dot ibm dot com
@ 2005-02-21 23:15 ` pinskia at gcc dot gnu dot org
  2005-02-21 23:35 ` yanliu at ca dot ibm dot com
  2005-02-24 23:45 ` jody-atd-030903 at atdesk dot com
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-02-21 23:15 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-02-21 19:17 -------
hmm, ICC 8.0 on ia32-linux produces the same mangled name for the variable too.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ABI


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


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

* [Bug c++/20123] mangled name of typeid doesn't encode cv-qualifer.
  2005-02-21 23:12 [Bug c++/20123] New: mangled name of typeid doesn't encode cv-qualifer yanliu at ca dot ibm dot com
  2005-02-21 23:15 ` [Bug c++/20123] " pinskia at gcc dot gnu dot org
@ 2005-02-21 23:35 ` yanliu at ca dot ibm dot com
  2005-02-24 23:45 ` jody-atd-030903 at atdesk dot com
  2 siblings, 0 replies; 4+ messages in thread
From: yanliu at ca dot ibm dot com @ 2005-02-21 23:35 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From yanliu at ca dot ibm dot com  2005-02-21 19:37 -------
For function parameters, the cv-qualifers should not be mangled. I suspect GCC 
treates this typeid as a function, thus ignoring the encoding of cv-qualifers. 
At least, the C++ ABI is not clear in this aspect.  

-- 


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


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

* [Bug c++/20123] mangled name of typeid doesn't encode cv-qualifer.
  2005-02-21 23:12 [Bug c++/20123] New: mangled name of typeid doesn't encode cv-qualifer yanliu at ca dot ibm dot com
  2005-02-21 23:15 ` [Bug c++/20123] " pinskia at gcc dot gnu dot org
  2005-02-21 23:35 ` yanliu at ca dot ibm dot com
@ 2005-02-24 23:45 ` jody-atd-030903 at atdesk dot com
  2 siblings, 0 replies; 4+ messages in thread
From: jody-atd-030903 at atdesk dot com @ 2005-02-24 23:45 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jody-atd-030903 at atdesk dot com  2005-02-24 19:33 -------
I am not on the gcc team, so feel free to take this with some reservation.

According to 5.2.8.5, the top-level cv-qualifier are stripped when calling typeid().

According to 3.9.3.[2,5], cv-qualifiers applied to array types apply to the
array elements, not to the array.

Thus, I think the name you see is correct.  In your example, you should be able
to see typeid() doing the right thing (and see that the top-level cv-qualifers
are being stripped) with...

int x[10];
assert(typeid(::v5) == typeid(int[10]));
assert(typeid(::v5) == typeid(x));
assert(strcmp(typeid(::v5).name(), typeid(x).name()) == 0);



-- 


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


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

end of thread, other threads:[~2005-02-24 19:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-21 23:12 [Bug c++/20123] New: mangled name of typeid doesn't encode cv-qualifer yanliu at ca dot ibm dot com
2005-02-21 23:15 ` [Bug c++/20123] " pinskia at gcc dot gnu dot org
2005-02-21 23:35 ` yanliu at ca dot ibm dot com
2005-02-24 23:45 ` jody-atd-030903 at atdesk dot com

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