Bogus warning from -Woverloaded-virtual checking

C. van Reeuwijk C.vanReeuwijk@twi.tudelft.nl
Wed Apr 8 07:38:00 GMT 1998


I think I've found a bug in the code that implements -Woverloaded-virtual.

The following code:

=-=-=-=
class Aggregate
{
public:
    virtual void foo();
    virtual void foo( int i );
};

class Shape: Aggregate
{
public:
    virtual void foo();
    void bar();			// Move or remove this, and the error is gone
    void foo( int i );
};

extern Shape processorArray;
=-=-=-=

causes the following compiler run:

[falcon] % gcc -c -Woverloaded-virtual t.cc
t.cc:5: warning: `Aggregate::foo(int)' was hidden
t.cc:11: warning:   by `Shape::foo()'

Although -Woverloaded-virtual is supposed to give this kind of warnings,
in this case the warning is (IMHO) unwarranted. It looks to me that
the administration of -Woverloaded-virtual is confused by other
functions inbetween overloaded variants of a function.

This bug has existed from the first egcs versions to the latest snapshot:
[falcon] % gcc -v
Reading specs from /usr/local/lib/gcc-lib/i586-pc-linux-gnulibc1/egcs-2.91.22/specs
gcc version egcs-2.91.22 980404 (gcc2 ss-980401 experimental)



-- 
Kees van Reeuwijk, Delft University of Technology
http://pds.twi.tudelft.nl/~reeuwijk



More information about the Gcc-bugs mailing list