From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3916 invoked by alias); 7 Dec 2002 20:56:01 -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 3897 invoked by uid 71); 7 Dec 2002 20:56:01 -0000 Resent-Date: 7 Dec 2002 20:56:01 -0000 Resent-Message-ID: <20021207205601.3896.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, catherin@ca.ibm.com Received: (qmail 31601 invoked by uid 61); 7 Dec 2002 20:53:06 -0000 Message-Id: <20021207205306.31600.qmail@sources.redhat.com> Date: Sat, 07 Dec 2002 12:56:00 -0000 From: catherin@ca.ibm.com Reply-To: catherin@ca.ibm.com To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c++/8861: mangling floating point literal in template arg expression X-SW-Source: 2002-12/txt/msg00441.txt.bz2 List-Id: >Number: 8861 >Category: c++ >Synopsis: mangling floating point literal in template arg expression >Confidential: no >Severity: critical >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Sat Dec 07 12:56:00 PST 2002 >Closed-Date: >Last-Modified: >Originator: Catherine Morton >Release: 3.2 >Organization: >Environment: >Description: I have a question about the way gcc is mangling a floating point literal used in a template argument ( this has changed from gcc 3.0.4 to 3.2 and I think the 3.2 output is in error ) ( note that I'm using 3.0.4 from aix and 3.2 from linux - both on the same IBM hardware ) Here is a simple(?) example: // --------------------- cut ----------------------------------- template struct A { A(int); }; const int N1 = 19; enum E {N2 = 27}; template void f(A) {} void g() { f<1,'x'>(37); } // ------------------------------ cut ------------------------------ gcc 3.0.4 (on aix) mangles the name as follows: _Z1fILi1ELc120EEv1AIXplT_cviLd4028AE147AE147AEEEE the floating point literal 12.34 is Ld4028AE147AE147AE this makes sense since the C++ ABI says: If floating-point arguments are accepted as an extension, their values should be encoded using a fixed-length lowercase hexadecimal string corresponding to the internal representation , high-order bytes first, without leading zeroes. (note that the ABI says lowercase hex while gcc always mangles it as upper-case hex) As a simple example I can reproduce the Hex number from double a = 12.34 with the following small test which reads the internal representation: #include int main(void ) { double a = 12.34; char *p ; int i ; p = ( char * ) &a ; for ( i = 0 ; i < 8 ; i++ ) { printf ( "%02x \n", ( unsigned char ) p[i] ) ; } } output: 40 28 ae 14 7a e1 47 ae This prints the internal representation matching the mangled name generated on 3.0.4 gcc (note that this simple program prints the same output whether its compiled on 3.0.4 (aix) or 3.2 (linux) Here's what I cannot figure out: using gcc 3.2 (on linux - same hardware), the mangled name is: _Z1fILi1ELc120EEv1AIXplT_cviLd0000000000700A3DA3D7C5704020000EEE the float literal 12.34 is mangled as: Ld0000000000700A3DA3D7C5704020000E I cannot figure out where this hex encoding came from... I think it must be a bug. information from gcc 3.0.4 in aix (gcc -v) Reading specs from /afs/tor/common/progs/gcc-3.0.4/aix43/lib/gcc-lib/powerpc-ibm-aix4.3.3.0/3.0.4/specs Configured with: ../gcc-3.0.4/configure --prefix=/afs/tor/common/progs/gcc-3.0.4/aix43 Thread model: single gcc version 3.0.4 information from gcc 3.2 on linux (gcc -v) Reading specs from /usr/lib/gcc-lib/powerpc-suse-linux/3.2/specs Configured with: ../configure --enable-threads=posix --prefix=/usr --with-local-prefix=/usr/local --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib --enable-languages=c,c++,f77,objc,java,ada --enable-libgcj --with-gxx-include-dir=/usr/include/g++ --with-slibdir=/lib --with-system-zlib --enable-shared --enable-__cxa_atexit powerpc-suse-linux Thread model: posix gcc version 3.2 >How-To-Repeat: >Fix: >Release-Note: >Audit-Trail: >Unformatted: