public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: d.frey@gmx.de To: gcc-gnats@gcc.gnu.org Subject: c++/7477: Type information thrown away Date: Fri, 02 Aug 2002 18:56:00 -0000 [thread overview] Message-ID: <20020803014737.16279.qmail@sources.redhat.com> (raw) >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:
next reply other threads:[~2002-08-03 1:56 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-08-02 18:56 d.frey [this message] 2002-09-13 16:29 nathan
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20020803014737.16279.qmail@sources.redhat.com \ --to=d.frey@gmx.de \ --cc=gcc-gnats@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).