[Bug c++/17920] New: add __attribute__((reimpl)) as a replacement for the (optional) virtual keyword for reimplementations of virtual functions

mutz at kde dot org gcc-bugzilla@gcc.gnu.org
Sun Oct 10 08:56:00 GMT 2004


The reason to have this is that quite often when overriding non-pure virtual 
methods, you will find yourself mistyping the signature of the 
reimplementation, which creates a new virtual method instead of overriding. The 
only indication of this happening is that you get hidden virtual warnings, but 
you also get them if there are overloads of the virtual method in the base 
class (as is often the case in the Qt library). 
 
What __attribute__((reimpl)) should do is emit an error or at least a warning 
if this happens: 
 
#define reimpl __attribute__((reimp)) 
struct A { virtual void foo() const; } 
struct B : public A { void reimpl foo(); } 
 
Warning: 'void foo()' does not override anything. 
Warning: candidates are: 
Warning: 'virtual A::foo() const'

-- 
           Summary: add __attribute__((reimpl)) as a replacement for the
                    (optional) virtual keyword for reimplementations of
                    virtual functions
           Product: gcc
           Version: 3.4.2
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mutz at kde dot org
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17920



More information about the Gcc-bugs mailing list