This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/7780: -Woverloaded-virtual generating false-positives
- From: Loren Osborn <linux_dr at yahoo dot com>
- To: bangerth at dealii dot org
- Cc: gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, nobody at gcc dot gnu dot org
- Date: 26 Nov 2002 13:33:26 -0800
- Subject: Re: c++/7780: -Woverloaded-virtual generating false-positives
- References: <20021122025626.2194.qmail@sources.redhat.com>
On Thu, 2002-11-21 at 18:56, bangerth@dealii.org wrote:
> Synopsis: -Woverloaded-virtual generating false-positives
>
> State-Changed-From-To: open->feedback
> State-Changed-By: bangerth
> State-Changed-When: Thu Nov 21 18:56:25 2002
> State-Changed-Why:
> I think the example you give should indeed give a warning:
> ----------------------
> class A
> {
> public:
> virtual int ThisFunctionShouldNotCauseAHidingWarning(char*);
> virtual int ThisFunctionShouldNotCauseAHidingWarning(char*,int);
> };
>
> class B : public A
> {
> public:
> virtual int ThisFunctionShouldNotCauseAHidingWarning(char*,int);
> };
>
> int main()
> {
> return 0;
> }
> -----------------------------------------
> After all the virtual function in the derived class
> hides indeed the one in the base class, independent of
> the fact that there are _two_ functions in the base class
> with the same name.
>
> What is it in this argumentation that you do not agree with?
>
> http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7780
As I understood it, this warning was to alert the programmer when they
overload a (hopefully virutal) function that they intended to override.
I am thinking of examples like:
class A
{
public:
virtual int ThisFunctionShouldCauseAHidingWarning(int);
};
class B : public A
{
public:
virtual int ThisFunctionShouldCauseAHidingWarning(long);
};
If this was not the intent of this warning, perhaps another warning
should catch this case.
Thanks,
-Loren