[LLVMbugs] [Bug 9182] New: spurious warning on overloaded-virtual

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Feb 9 15:00:37 PST 2011


http://llvm.org/bugs/show_bug.cgi?id=9182

           Summary: spurious warning on overloaded-virtual
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: nlewycky at google.com
                CC: llvmbugs at cs.uiuc.edu, akyrtzi at gmail.com,
                    dgregor at apple.com


This code warns that the derived class hides a virtual function -- except that
it doesn't:

  struct Base {
    virtual void foo(int);
  };

  void Base::foo(int) { }

  struct Derived : public Base {
    virtual void foo(int);   
    void foo(int, int);   
  };

note that if you move the out-of-line Base::foo def'n after struct Derived,
then it doesn't warn any more. Here's the clang output:

  $ clang++ -c x.cc -Woverloaded-virtual 
  x.cc:9:8: warning: 'Derived::foo' hides overloaded virtual function
        [-Woverloaded-virtual]
    void foo(int, int);
         ^
  x.cc:5:12: note: hidden overloaded virtual function 'Base::foo' declared here
  void Base::foo(int) { }
             ^
  1 warning generated.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list