This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/7008: unexpected error message "var was not declared in this scope"
- From: "Rafal Dabrowa" <rdabrowa at poczta dot onet dot pl>
- To: <rdabrowa at poczta dot onet dot pl>, <gcc-gnats at gcc dot gnu dot org>,<gcc-prs at gcc dot gnu dot org>, <gcc-bugs at gcc dot gnu dot org>, <nobody at gcc dot gnu dot org>
- Date: Sun, 14 Jul 2002 13:58:10 +0200
- Subject: Re: c++/7008: unexpected error message "var was not declared in this scope"
I have a few additional remarks about compiler behavior.
Compiler should not take a global variable because
use of local one is forbidden. This is unclear and confusing
people. Compiler should put an error message instead.
Consider the following code:
const int N = 500;
void f(int var) {
const int N = 5;
struct { char str[N]; } z1; // error: use of local variable is
forbidden here
struct { char str[::N]; } z2; // global variable used, ok
}
Also, error text: "var was not declared in this scope" is
unclear, too. In my opinion, better is such like "use of local variable
is not allowed here".
Rafal Dabrowa