public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: catherin@ca.ibm.com To: gcc-gnats@gcc.gnu.org Subject: c++/8861: mangling floating point literal in template arg expression Date: Sat, 07 Dec 2002 12:56:00 -0000 [thread overview] Message-ID: <20021207205306.31600.qmail@sources.redhat.com> (raw) >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 <int I> struct A { A(int); }; const int N1 = 19; enum E {N2 = 27}; template <int I, char J> void f(A<I+int(12.34)>) {} 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 <stdio.h> 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:
reply other threads:[~2002-12-07 20:56 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20021207205306.31600.qmail@sources.redhat.com \ --to=catherin@ca.ibm.com \ --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).