From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21323 invoked by alias); 29 Jun 2002 18:56:04 -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 21303 invoked by uid 71); 29 Jun 2002 18:56:03 -0000 Resent-Date: 29 Jun 2002 18:56:03 -0000 Resent-Message-ID: <20020629185603.21302.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, ofv@wanadoo.es Received: (qmail 17513 invoked by uid 61); 29 Jun 2002 18:51:56 -0000 Message-Id: <20020629185156.17512.qmail@sources.redhat.com> Date: Sat, 29 Jun 2002 13:36:00 -0000 From: ofv@wanadoo.es Reply-To: ofv@wanadoo.es To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c++/7166: Non-type template instantiation fails for pointer types X-SW-Source: 2002-06/txt/msg00723.txt.bz2 List-Id: >Number: 7166 >Category: c++ >Synopsis: Non-type template instantiation fails for pointer types >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: rejects-legal >Submitter-Id: net >Arrival-Date: Sat Jun 29 11:56:02 PDT 2002 >Closed-Date: >Last-Modified: >Originator: ofv@wandoo.es >Release: gcc 3.1 >Organization: >Environment: d:/Des/cppExp # gcc -v Reading specs from t:/msys/1.0/mingw/bin/../lib/gcc-lib/mingw32/3.1/specs Configured with: ../gcc/configure --with-gcc --with-gnu-ld --with-gnu-as --host=mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls --enable-languages=f77,c++,objc,ada --disable-win32-registry --disable-shared Thread model: win32 gcc version 3.1 It fails too with gcc 3.1 (cygwin) and gcc 2.95.3-6 (MinGW) >Description: Instantiating a template with a non-type parameter of pointer type makes the compiler complain about the parameter not being an object with external linkage. So far I've only tried with char* and int*. It works for char[] and int[]. See test case below. >How-To-Repeat: Compiling this: /// begin template class FooChar {}; char *strPointer = "Hi!"; char strArray[] = "Hi!"; template class FooInt {}; int *intPointer = 0; int intArray[] = { 1, 2 }; int main() { FooChar fooCharPointer; FooChar fooCharArray; FooInt fooIntPointer; FooInt fooIntArray; } /// end produces g++ -c gccbugTPointer.cpp gccbugTPointer.cpp: In function `int main()': gccbugTPointer.cpp:12: `strPointer' is not a valid template argument gccbugTPointer.cpp:12: it must be the address of an object with external linkage gccbugTPointer.cpp:12: ISO C++ forbids declaration of `fooPointer' with no type gccbugTPointer.cpp:15: `intPointer' is not a valid template argument gccbugTPointer.cpp:15: it must be the address of an object with external linkage gccbugTPointer.cpp:15: ISO C++ forbids declaration of `fooIntPointer' with no type >Fix: >Release-Note: >Audit-Trail: >Unformatted: