https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85043
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |msebor at gcc dot gnu.org --- Comment #8 from Martin Sebor <msebor at gcc dot gnu.org> --- It sounds like the report is not about the documentation but about the term "useless" in the text of the warning. Useless implies the cast serves no useful purpose which is not true in the test case. If we wanted to go by the documentation then the warning should say something like "object cast to its own type" but I don't think that would be helpful or reflect the intended purpose of the warning: to point out casts that do, in fact, serve no useful purpose. I would think that changing both when the warning is issued and how it's documented is the appropriate solution. That said, I don't think the distinction between class types and non-class types is essential. The warning also triggers for casts that create a (temporary) rvalue from an lvalue, as in: extern int i; const int &r = (int)i; // bogus -Wuseless-cast even though these casts are also not useless. (Ditto when i itself is a reference.) Fixing this shouldn't require introducing levels.