From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26469 invoked by alias); 10 Apr 2003 21:16: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 26320 invoked by uid 71); 10 Apr 2003 21:16:01 -0000 Resent-Date: 10 Apr 2003 21:16:01 -0000 Resent-Message-ID: <20030410211601.26318.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, reichelt@igpm.rwth-aachen.de Received: (qmail 24533 invoked by uid 48); 10 Apr 2003 21:14:11 -0000 Message-Id: <20030410211411.24532.qmail@sources.redhat.com> Date: Thu, 10 Apr 2003 21:16:00 -0000 From: reichelt@igpm.rwth-aachen.de Reply-To: reichelt@igpm.rwth-aachen.de To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c++/10371: [3.4 regression] misleading error message for illegal member access X-SW-Source: 2003-04/txt/msg00466.txt.bz2 List-Id: >Number: 10371 >Category: c++ >Synopsis: [3.4 regression] misleading error message for illegal member access >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: change-request >Submitter-Id: net >Arrival-Date: Thu Apr 10 21:16:01 UTC 2003 >Closed-Date: >Last-Modified: >Originator: Volker Reichelt >Release: gcc 3.4-20030402 >Organization: >Environment: i686-pc-linux-gnu >Description: Compiling the following code with "g++ -c" I get an error message which is quite misleading IMHO: ----------------------snip here--------------------- struct A { int i; }; template struct B { int foo() { return A::i; } }; void bar() { B<0>().foo(); } ----------------------snip here--------------------- msg.cc: In member function `int B< >::foo() [with int = 0]': msg.cc:11: instantiated from here msg.cc:8: error: 'struct B<0>' has no member named 'i' We try to access "A::i" which is a member of A and not of B<0> in an illegal fashion. There are (at least) two ways to make the code legal: a) make "i" static or b) derive "B" from "A". Compilers on the release branch at least give a hint w.r.t. b): msg.cc: In member function `int B< >::foo() [with int = 0]': msg.cc:11: instantiated from here msg.cc:8: error: type `A' is not a base type for type `B<0>' Although this is only correct in some cases, I rate the new error message as a regression. For related issues see PR 9443. >How-To-Repeat: >Fix: >Release-Note: >Audit-Trail: >Unformatted: