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

Arthur O'Dwyer <arthur.j.odwyer at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |arthur.j.odwyer at gmail dot 
com

--- Comment #4 from Arthur O'Dwyer <arthur.j.odwyer at gmail dot com> ---
jynelson: Static-casting from Base& to Derived& is the foundation of the
"Curiously Recurring Template Pattern" in C++, and therefore can't be allowed
to trigger any diagnostic with -Wall -Wextra. (Many industry codebases build
with -Wall -Wextra, and also use the CRTP.)
*Aside* from that practical consideration, I don't think there's anything wrong
with casting from one type to another. The point of type-cast syntax is to say
"Don't worry, compiler, I know what I'm doing." If one doesn't know what one's
doing, then one shouldn't use casts at all, and just stick to the implicit
conversions. It's already an error to *implicitly convert* from Base& to
Derived&, so if you stick to implicit conversions you'll get exactly the
behavior you want.

Suggest closing this issue as NOTABUG.
But see also #96765 (for this kind of cast specifically *inside a
constructor*).

Reply via email to