From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22906 invoked by alias); 3 Aug 2002 01:56:02 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 22887 invoked by uid 71); 3 Aug 2002 01:56:01 -0000 Resent-Date: 3 Aug 2002 01:56:01 -0000 Resent-Message-ID: <20020803015601.22886.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, d.frey@gmx.de Received: (qmail 16280 invoked by uid 61); 3 Aug 2002 01:47:37 -0000 Message-Id: <20020803014737.16279.qmail@sources.redhat.com> Date: Fri, 02 Aug 2002 18:56:00 -0000 From: d.frey@gmx.de Reply-To: d.frey@gmx.de To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c++/7477: Type information thrown away X-SW-Source: 2002-08/txt/msg00045.txt.bz2 List-Id: >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 #include #include 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: