[LLVMbugs] [Bug 12459] New: False positive for call to pure virtual member function warning caused by a cast
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Wed Apr 4 08:58:56 PDT 2012
http://llvm.org/bugs/show_bug.cgi?id=12459
Bug #: 12459
Summary: False positive for call to pure virtual member
function warning caused by a cast
Product: clang
Version: trunk
Platform: Other
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: l.lunak at suse.cz
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
$ cat a.cpp
struct A { virtual void foo() = 0; };
struct B : A { B(); virtual void foo(); };
B::B() { static_cast< A* >( this )->foo(); }
void B::foo() {}
int main() { B b; }
$ clang++ -v
clang version 3.1 (trunk 153819)
Target: x86_64-unknown-linux-gnu
Thread model: posix
$ clang++ a.cpp
a.cpp:3:10: warning: call to pure virtual member function 'foo'; overrides of
'foo' in subclasses are not available in the
constructor of 'A'
B::B() { static_cast< A* >( this )->foo(); }
^
a.cpp:1:12: note: 'foo' declared here
struct A { virtual void foo() = 0; };
^
1 warning generated.
$ ./a.out
[no abort, runs fine]
Stepping through or even just running this testcase shows that B::B() calls
B::foo() and not A::foo(), despite the explicit cast and the warning. The false
warning is not generated without the explicit cast.
--
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