https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61295

            Bug ID: 61295
           Summary: g++ Explicit qualification promote call to pure
                    virtual to resolvable method address without
                    warning/error
           Product: gcc
           Version: 4.10.0
            Status: UNCONFIRMED
          Severity: trivial
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hermier at frugalware dot org

Created attachment 32847
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=32847&action=edit
Test case

Hi,

When trying to compile the attached test case, g++ don't issue a warning/error
when compiling, but only show the issue at link time:

$ g++ bug.cpp -o bug 
/tmp/ccBPniCm.o: In function `B::foo()':
bug.cpp:(.text._ZN1B3fooEv[_ZN1B3fooEv]+0x14): undefined reference to
`A::dummy()'
collect2: error: ld returned 1 exit status

The attached patch handle the case and propose 2 alternatives to resolves the
issue:
First one is a plain error, since according to iso c++ say:
10.3-15: "Explicit qualification with the scope operator suppresses the virtual
call mechanism."
And as such suppressing the virtual call on a pure virtual method is
impossible.

Second one, since it is not explicitly said how to handle pure virtual method,
one can think that calling a pure virtual can restore the virtual call.

In all the case, this make the compiler more verbose and easier to debug:

gcc/bin/c++ bug.cpp -o bug
bug.cpp: In member function 'void B::foo()':
bug.cpp:15:26: error: non virtual call on pure virtual 'virtual void
A::dummy()' is undefined behaviour
                 A::dummy();
                          ^

Cheers

Reply via email to