This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

c++/10291: error referencing a static local from a local struct in termplate code


>Number:         10291
>Category:       c++
>Synopsis:       error referencing a static local from a local struct in termplate code
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Wed Apr 02 01:06:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     sebor at roguewave dot com
>Release:        3.2
>Organization:
>Environment:

>Description:
The well-fomed program below fails to compile with gcc 3.2.

Regards
Martin
>How-To-Repeat:
$ cat t.cpp; gcc --version; gcc t.cpp
template <class T>
int foo ()
{
    static int i;

    struct S {
        int bar () {
            return i;
        }
    } s;

    return s.bar ();
}

int main ()
{
    foo<int>();
}

gcc (GCC) 3.2
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

t.cpp: In member function `int foo()::S::bar() [with T = int]':
t.cpp:12:   instantiated from `int foo() [with T = int]'
t.cpp:17:   instantiated from here
t.cpp:8: `i' undeclared (first use this function)
t.cpp:8: (Each undeclared identifier is reported only once for each function it 
   appears in.)
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]