https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82269
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> --- I agree that in this case the caller is wrong and should do pointer_cast<T> not pointer_cast<const T>. The warning found a bug. In general the warning is a bit too noisy, but we already have a bug report about it.