[LLVMbugs] [Bug 8580] New: clang error recovery goes wrong after qualifier mismatch
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Wed Nov 10 02:21:44 PST 2010
http://llvm.org/bugs/show_bug.cgi?id=8580
Summary: clang error recovery goes wrong after qualifier
mismatch
Product: clang
Version: 2.8
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P
Component: Frontend
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: richard-llvm at metafoo.co.uk
CC: llvmbugs at cs.uiuc.edu
Cut down testcase:
struct Foo
{
virtual const Foo *Get() const { return this; }
};
struct Bar : Foo
{
} f;
const Foo *GetFoo() { return &f; }
int main()
{
Foo *foo = GetFoo();
dynamic_cast<const Bar*>(foo->Get());
}
g++ does well here:
test.cpp: In function ‘int main()’:
test.cpp:13: error: invalid conversion from ‘const Foo*’ to ‘Foo*’
clang++ does badly:
test.cpp:13:8: error: cannot initialize a variable of type 'Foo *' with an
rvalue of type 'Foo const *'
Foo *foo = GetFoo();
^ ~~~~~~~~
test.cpp:14:31: error: expected ')'
dynamic_cast<const Bar*>(foo->Get());
^
test.cpp:14:27: note: to match this '('
dynamic_cast<const Bar*>(foo->Get());
^
2 errors generated.
The first error is OK (though a fixit adding in the const would be nice). The
second error is weird and unhelpful. I get the same error if I instead declare
foo as type void: even if this were a correct error, it would seem more helpful
to produce the "member reference type 'void' is not a pointer" error.
--
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