From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6328 invoked by alias); 2 Apr 2003 01:27:20 -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 6309 invoked by uid 48); 2 Apr 2003 01:27:20 -0000 Date: Wed, 02 Apr 2003 01:27:00 -0000 Message-ID: <20030402012720.6308.qmail@sources.redhat.com> To: gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org, sebor@roguewave.com From: bangerth@dealii.org Reply-To: bangerth@dealii.org, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org, sebor@roguewave.com, gcc-gnats@gcc.gnu.org Subject: Re: c++/10291: error referencing a static local from a local struct in termplate code X-SW-Source: 2003-04/txt/msg00045.txt.bz2 List-Id: Synopsis: error referencing a static local from a local struct in termplate code State-Changed-From-To: open->analyzed State-Changed-By: bangerth State-Changed-When: Wed Apr 2 01:27:20 2003 State-Changed-Why: Confirmed with 2.95, 3.2, 3.3. With 3.4, it compiles, but doesn't link (see below). This testcase actually has rather interesting questions to offer for people who like thinking about the implications of two-stage name lookup, such as - 'i' being a variable in a template dependent namespace, it shouldn't be seen during first phase parsing - one would then need to qualify it - but how do you qualify function-local objects? For 3.4: as said, it compiles but doesn't link: g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ x.cc /tmp/cceV3jl1.o: In function `int foo()::S::bar()': /tmp/cceV3jl1.o(.text+0x1c): undefined reference to `i' collect2: ld returned 1 exit status Something is not quite right here -- take this small modification (introduce another -- global -- variable 'i', give initializers to variables, and generate a return value): -------------------------- int i = 0; template int foo () { static int i = 1; struct S { int bar () { return i; } } s; return s.bar (); } int main () { return foo(); } ------------------------------ This links, but surprisingly returns zero! g/x> ./a.out ; echo $? 0 Weird... W. http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10291