From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31089 invoked by alias); 23 Dec 2002 17:36: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 31053 invoked by uid 71); 23 Dec 2002 17:36:01 -0000 Resent-Date: 23 Dec 2002 17:36:01 -0000 Resent-Message-ID: <20021223173601.31052.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 30619 invoked by uid 61); 23 Dec 2002 17:35:04 -0000 Message-Id: <20021223173504.30618.qmail@sources.redhat.com> Date: Mon, 23 Dec 2002 09:36: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++/9043: incorrect name mangling for array dimension in template function X-SW-Source: 2002-12/txt/msg01239.txt.bz2 List-Id: >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. ::= A _ ::= A [] _ When the dimension is an expression involving template parameters, the second production is used. Thus, the declarations: template 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 void f36(int (*)[2]) {} static const int I=1; template void f36(int (*)[2]); void (*g36)(int (*)[2]) = &f36; // --------------------------------- 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: