[Bug c++/89722] [8/9 regression] strange warning: type qualifiers ignored on cast result type [-Wignored-qualifiers]

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Mar 15 14:34:00 GMT 2019


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

--- Comment #11 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Martin Sebor from comment #6)
> But the code above doesn't trigger either warning when compiled as C.  I
> think that suggests that either the manual should be updated to explain the
> difference or the two front ends should be made to behave the same way.  As

C++ is clear that a prvalue of non-class type is cv-unqualified, I assume
that's also true in C. But it matters less for C, because (except for
extensions like __typeof__) the cv-qualifiers of an rvalue don't really matter.
In C++ they affect overloading, template argument deduction, decltype results
etc.

> a data point, Clang doesn't warn in either C or C++ modes on this code so I
> wonder if G++ is being overly pedantic here, especially in the typeof cases.

As I noted in PR 80544 comment 0, EDG warns about casts to cv-qualified scalar
types, and was my inspiration for our warning.


More information about the Gcc-bugs mailing list