c++/7008: unexpected error message "var was not declared in this scope"

rdabrowa@poczta.onet.pl rdabrowa@poczta.onet.pl
Wed Jun 12 16:07:00 GMT 2002


>Number:         7008
>Category:       c++
>Synopsis:       unexpected error message "var was not declared in this scope"
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Wed Jun 12 13:16:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Rafal Dabrowa
>Release:        gcc-3.1
>Organization:
>Environment:

>Description:
Below is simple program, which demonstrates problem.
During compile, unexpected error message appears:

bug1.cc: In instantiation of `doit(T) [with T = int]::st':
bug1.cc:5:   instantiated from `void doit(T) [with T = int]'
bug1.cc:10:   instantiated from here
bug1.cc:5: `var' was not declared in this scope

This bug occurs in gcc-2.96 and some earlier versions, too.
(I have it submitted to RedHat bugzilla as a gcc-2.96 bug)
>How-To-Repeat:
Please compile code specified below using g++:

template <class T> void doit( T var )
{
    struct st { int i; char s[sizeof(var)]; } zz;
}

int main() { doit(3); }
>Fix:

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



More information about the Gcc-bugs mailing list