public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/7477: Type information thrown away
@ 2002-08-02 18:56 d.frey
  0 siblings, 0 replies; 2+ messages in thread
From: d.frey @ 2002-08-02 18:56 UTC (permalink / raw)
  To: gcc-gnats


>Number:         7477
>Category:       c++
>Synopsis:       Type information thrown away
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Fri Aug 02 18:56:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     d.frey@gmx.de
>Release:        unknown-1.0
>Organization:
>Environment:
linux, gcc 3.1
>Description:
Consider the following code:

#include <string>
#include <iostream>
#include <typeinfo>

namespace base
{
   struct string : public ::std::string
   {
      template< typename T >
      string( const T& s )
            : ::std::string( s, sizeof( s ) / sizeof( *s ) - 1 )
      {
         std::cout << typeid( T ).name() << std::endl;
      }
   };
}

void f( const base::string& s ) 
{
   std::cout << s << std::endl;
}

int main()
{
   base::string s = "Hello, world!";
   std::cout << s << std::endl;
   
   f( "Hello, world!" );
}

The output for the GCC 3.1 is:

A14_c
Hello, world!
PKc
Hel

Which is IMHO not correct. The base::string that is taken by f() should get the same type as the explicitly constructed base::string. For further discussion see the thread in csc++ where James Kanze also provided some references to the standard. I am not sure if it really is a bug, but if it isn't, please show me a reference to the standard which makes it legal to throw away the type information. :)

Regards, Daniel
>How-To-Repeat:

>Fix:

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


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

* Re: c++/7477: Type information thrown away
@ 2002-09-13 16:29 nathan
  0 siblings, 0 replies; 2+ messages in thread
From: nathan @ 2002-09-13 16:29 UTC (permalink / raw)
  To: d.frey, gcc-bugs, gcc-prs, nobody

Synopsis: Type information thrown away

State-Changed-From-To: open->analyzed
State-Changed-By: nathan
State-Changed-When: Fri Sep 13 16:29:55 2002
State-Changed-Why:
    confirmed. this may be related to 3518

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


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

end of thread, other threads:[~2002-09-13 23:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-02 18:56 c++/7477: Type information thrown away d.frey
2002-09-13 16:29 nathan

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