https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65293
Bug ID: 65293 Summary: improve error message on static_casting incomplete types. Product: gcc Version: 5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: chengniansun at gmail dot com It took me a while to figure out that the cause of the error is the incomplete definition of destination type. I wonder whether it is possible to improve the error message by mentioning "incomplete", similar to what Clang does. I believe doing this will provide more information to developers to fix this type of errors. $: cat t.cc class A; class B; void f(const B &b) { const A &a = static_cast<const A&>(b); } $: $: $: ~/tools/gcc-install/bin/g++ -c t.cc t.cc: In function ‘void f(const B&)’: t.cc:5:39: error: invalid static_cast from type ‘const B’ to type ‘const A&’ const A &a = static_cast<const A&>(b); ^ $: $: clang++ -c t.cc t.cc:5:16: error: no viable conversion from 'const B' to incomplete type 'const A' const A &a = static_cast<const A&>(b); ^ ~ t.cc:1:7: note: forward declaration of 'A' class A; ^ 1 error generated. $: