From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2113 invoked by alias); 17 Jan 2002 16:16: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 2075 invoked by uid 71); 17 Jan 2002 16:16:02 -0000 Resent-Date: 17 Jan 2002 16:16:02 -0000 Resent-Message-ID: <20020117161602.2074.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, wirawan0@hotmail.com Received:(qmail 31222 invoked by uid 61); 17 Jan 2002 16:10:29 -0000 Message-Id:<20020117161029.31220.qmail@sources.redhat.com> Date: Thu, 17 Jan 2002 08:16:00 -0000 From: wirawan0@hotmail.com Reply-To: wirawan0@hotmail.com To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version:gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c++/5413: g++ fails to understand class template's typedef X-SW-Source: 2002-01/txt/msg00615.txt.bz2 List-Id: >Number: 5413 >Category: c++ >Synopsis: g++ fails to understand class template's typedef >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: rejects-legal >Submitter-Id: net >Arrival-Date: Thu Jan 17 08:16:01 PST 2002 >Closed-Date: >Last-Modified: >Originator: Wirawan Purwanto >Release: gcc-2.95.3-5 and gcc-2.95.3-6 >Organization: >Environment: mingw32 1.1 (gcc-2.95.3-6), but also other gcc 2.95.x >Description: Help GCC developer! [pls read with fixed-width font; the same document could also be found in the attachment] I found an annoying bug in g++ recently. A simplified test program is supplied below. This file alone is enough to reproduce the error. I have tested this program under the following compilers: 1. g++ 2.95.2, mingw32 distribution. Typing "g++ -v" returns: Reading specs from e:\APPS\GCC2.95.2\BIN\..\lib\gcc-lib\mingw32\2.95.2\specs gcc driver version 2.95.2 19991024 (release) executing gcc version 2.95.2-mingw snapshot 20010329 2. g++ 2.95.3-6, distributed in mingw32 version 1.1. Typing "g++ -v" returns: Reading specs from c:/usr/gcc/bin/../lib/gcc-lib/mingw32/2.95.3-6/specs gcc version 2.95.3-6 (mingw special) 3. g++ 2.95.3, in Mandrake Linux version . Typing "g++ -v" returns: Reading specs from /usr/lib/gcc-lib/i586-mandrake-linux/2.95.3/specs gcc version 2.95.3 19991030 (prerelease) This error is related to the template feature in the compiler. The error can be briefly desrcribed as follows: Suppose we declare a class template called PARENT, and in this class we make a typedef PARENT_type. Any type should work (I have tried arrays and structs and ints). Then we declare another class template, called CHILD, whose base class is _another_ class template (given in the template parameter of CHILD). Now we want to use the typedefs declared in the base class. For example, here I typed: typedef typename parent_template::PARENT_type CHILD_type1; in the declaration of class CHILD. This is OK as long as we use CHILD_type1 within the declaration of the class. But once we declare it OUTSIDE the class declaration (i.e. in the definition of method CHILD::this_is_refused(CHILD_type1 xx) <--+ | below, the compiler complains (line number can vary, but it refers to | the line containing { } after the statement above): -------------------+ gcc-template-bug1.cpp:100: `parent_template' is not a class, struct, or union type gcc-template-bug1.cpp:100: syntax error before `{' The fact that parent_template is used as a base class implies that parent_template must be a class. Why can't we assume that here? BTW I have checked this testcase against Borland C++ 5.5 and Compaq C++ (in Alpha machine), they don't complain about this. Also ecgs 2.96 for linux-alpha does not complain--but AFAIK this version is not supported. Please help me! Is there any solution or patch to this problem? I would appreciate if you cc: also your reply to my address below. Wirawan >How-To-Repeat: See attached file, all are there. >Fix: Temporary workaround is by create the definition of the class method INSIDE the declaration of class. But this is nasty for large methods! >Release-Note: >Audit-Trail: >Unformatted: