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++/9043: incorrect name mangling for array dimension in template function Date: Mon, 23 Dec 2002 09:36:00 -0000 [thread overview] Message-ID: <20021223173504.30618.qmail@sources.redhat.com> (raw) >Number: 9043 >Category: c++ >Synopsis: incorrect name mangling for array dimension in template function >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Mon Dec 23 09:36:01 PST 2002 >Closed-Date: >Last-Modified: >Originator: Catherine Morton >Release: gcc 3.2 >Organization: >Environment: 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 >Description: The C++ ABI for name mangling has 2 production rules for mangling array dimensions: quoting from the ABI: Array types encode the dimension (number of elements) and the element type. Note that "array" parameters to functions are encoded as pointer types. For variable length arrays (C99 VLAs), the dimension (but not the '_' separator) is omitted. <array-type> ::= A <positive dimension number> _ <element type> ::= A [<dimension expression>] _ <element type> When the dimension is an expression involving template parameters, the second production is used. Thus, the declarations: template<int I> void foo (int (&)[I + 1]) { } template void foo<2> (int (&)[3]); produce the mangled name "_Z3fooILi2EEvRAplT_Li1E_i". gcc mangles the name in the example the same way... however for this testcase: // ------------- abc.cpp ------------ template <int I> void f36(int (*)[2]) {} static const int I=1; template void f36<I>(int (*)[2]); void (*g36)(int (*)[2]) = &f36<I>; // --------------------------------- gcc mangles the name as follows _Z3f36ILi1EEvPALi2E_i The array dimension '2' has been mangled as a literal expression 'Li2E' So gcc has taken the 2nd production for the array dimension If I'm interpreting the standard correctly, this is not correct. The array dimension should only be encoded as an expression if it references the template arguments The correct mangled name should be: _Z3f36ILi1EEvPA2_i (taking the first production instead of the 2nd one) >How-To-Repeat: g++ -c abc.cpp nm abc.o >Fix: >Release-Note: >Audit-Trail: >Unformatted:
reply other threads:[~2002-12-23 17:36 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=20021223173504.30618.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).