This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Missing warning (gcc version 2.97 20010122)
- To: gcc-bugs at gcc dot gnu dot org
- Subject: Missing warning (gcc version 2.97 20010122)
- From: Carlo Wood <carlo at alinoe dot com>
- Date: Mon, 5 Feb 2001 17:54:59 +0100
Perhaps I should have posted this to gcc@, but well - *I* think
that a warning is missing here ;).
The following code example:
class A {
public:
int f(void);
};
namespace N {
int i = 0;
int A::f(void)
{
return i; // line 12
}
}
gives as error:
test.cc: In member function `int A::f()':
test.cc:12: `i' undeclared (first use this function)
The reason for this might be obvious in this small test case, but it
is not in a large application. Therefore I suggest to add this
warning:
test.cc:10: warning: class A is not defined in namespace N
--
Carlo Wood <carlo@alinoe.com>
========================================================================
PS Full output
~/c++/libcw/src/libcwd>g++-cvs -v -c test.cc
Reading specs from /usr/local/gcc/lib/gcc-lib/i686-pc-linux-gnu/2.97/specs
Configured with: ../gcc-cvs/configure --prefix=/usr/local/gcc --enable-shared --with-gnu-as --with-gnu-ld --enable-languages=c++ : (reconfigured) : (reconfigured) ../gcc-cvs/configure --prefix=/usr/local/gcc --enable-shared --with-gnu-as --with-gnu-ld --enable-languages=c++
gcc version 2.97 20010122 (experimental)
/usr/local/gcc/lib/gcc-lib/i686-pc-linux-gnu/2.97/cc1plus -v -iprefix /usr/local/bin/../lib/gcc-lib/i686-pc-linux-gnu/2.97/ -D__GNUC__=2 -D__GNUC_MINOR__=97 -D__GNUC_PATCHLEVEL__=0
-D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__STDC_HOSTED__=1 -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ test.cc -D__GNUG__=2 -D_GNU_SOURCE -D__GXX_ABI_VERSION=100 -quiet -dumpbase test.cc -version -o /tmp/ccvG2yMF.s
GNU CPP version 2.97 20010122 (experimental) (cpplib) (i386 Linux/ELF)
GNU CPP version 2.97 20010122 (experimental) (cpplib) (i386 Linux/ELF)
GNU C++ version 2.97 20010122 (experimental) (i686-pc-linux-gnu)
compiled by GNU C version 2.97 20010122 (experimental).
ignoring nonexistent directory "/usr/local/include/g++-"
ignoring nonexistent directory "/usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.97/include"
ignoring nonexistent directory "/usr/local/i686-pc-linux-gnu/include"
ignoring nonexistent directory "/usr/local/gcc/i686-pc-linux-gnu/include/g++-"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/gcc/include/g++-
/usr/local/include
/usr/local/gcc/lib/gcc-lib/i686-pc-linux-gnu/2.97/include
/usr/local/gcc/i686-pc-linux-gnu/include
/usr/include
End of search list.
test.cc: In member function `int A::f()':
test.cc:12: `i' undeclared (first use this function)
test.cc:12: (Each undeclared identifier is reported only once for each function
it appears in.)