This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
abstract class warnings
- To: egcs-bugs at cygnus dot com
- Subject: abstract class warnings
- From: Nathan Sidwell <nathan at cs dot bris dot ac dot uk>
- Date: Tue, 30 Jun 1998 15:46:28 +0100
- Organization: Computer Science Dept, Bristol University
This is about a problem with diagnostic messages regarding abstract
functions.
When you try to define an object of type abstract class, egcs gives an
error message which tells you which functions are abstract. Two
improvements could be made to the diagnostic
1) the line number reported is the point of the object definition, not
the point where the class or the virtual member function was declared.
So you have to go hunting through the code yourself to find out what
it's talking about. (compared to overloading ambiguity, which tells you
where you are and lists all the alternatives and their
declaration/definition locations.
2) abstract functions in derrived classes are mentioned multiple times
(apparently once for each base class).
The problem exists with both egcs-1.0.3a and the 19980628 snapshot. Here
is an example program,
--begin program
// abstract class warnings
class C
{
public:
virtual void fn() = 0;
};
class D : public C
{
public:
virtual void fnD() = 0;
};
void f()
{
D obj;
}
--end program
Here is the session log,
--begin log
nathan@laie:9791>uname -a
SunOS laie 5.5.1 Generic sun4u sparc SUNW,Ultra-1
nathan@laie:9792>egcs-0628-g++ -c foo2.cc -v
Reading specs from
/home/staff/nathan/solaris/local/SunOS_5/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.91.43/specs
gcc version egcs-2.91.43 19980628 (gcc2 ss-980502 experimental)
/home/staff/nathan/solaris/local/SunOS_5/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.91.43/cpp
-lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus
-D__GNUC_MINOR__=91 -Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4 -D__sparc__
-D__sun__ -D__unix__ -D__svr4__ -D__SVR4 -D__sparc -D__sun -D__unix
-Asystem(unix) -Asystem(svr4) -D__EXCEPTIONS -D__GCC_NEW_VARARGS__
-Acpu(sparc) -Amachine(sparc) foo2.cc /var/tmp/ccyMOc6y
GNU CPP version egcs-2.91.43 19980628 (gcc2 ss-980502 experimental)
(sparc)
#include "..." search starts here:
#include <...> search starts here:
/home/staff/nathan/solaris/local/include/g++
/usr/local/include
/home/staff/nathan/solaris/local/SunOS_5/sparc-sun-solaris2.5.1/include
/home/staff/nathan/solaris/local/SunOS_5/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.91.43/include
/usr/include
End of search list.
/home/staff/nathan/solaris/local/SunOS_5/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.91.43/cc1plus
/var/tmp/ccyMOc6y -quiet -dumpbase foo2.cc -version -o /var/tmp/ccm2IA47
GNU C++ version egcs-2.91.43 19980628 (gcc2 ss-980502 experimental)
(sparc-sun-solaris2.5.1) compiled by GNU C version 2.8.1.
foo2.cc: In function `void f()':
foo2.cc:16: cannot declare variable `obj' to be of type `D'
foo2.cc:16: since the following virtual functions are abstract:
foo2.cc:16: void D::fnD()
foo2.cc:16: void C::fn()
foo2.cc:16: void D::fnD()
--end log
As you can see D::fnD is mentioned twice and the only lin mentioned is
foo2.cc:16. The output I'd prefer to see would be something like,
foo2.cc: In function `void f()':
foo2.cc:16: cannot declare variable `obj' to be of type `D'
foo2.cc:16: since the following virtual functions are abstract:
foo2.cc:11: void D::fnD()
foo2.cc:5: void C::fn()
thanks,
nathan
--
Dr Nathan Sidwell :: Computer Science Department :: Bristol University
You can up the bandwidth, but you can't up the speed of light
nathan@acm.org http://www.cs.bris.ac.uk/~nathan/ nathan@cs.bris.ac.uk