-Wcast-qual consistency with initialization conversion and double pointer types
Ryan Libby
rlibby@gmail.com
Sun Jun 16 18:54:34 GMT 2024
On Sun, Jun 16, 2024 at 12:33 AM Martin Uecker <muecker@gwdg.de> wrote:
>
>
> I think it should not warn about:
>
> char *x;
> *(char * volatile *)&x;
>
> as this is regular qualifier adding and this is
> a bug in GCC.
>
I can file a bug if it is indeed one.
> I would guess it looks at all qualifiers added at
> all level but should ignore the one on the first level.
>
> Martin
It looks to me like handle_warn_cast_qual() does ignore qualifiers at
the outermost level, but it is only examining the cast itself (so e.g.
it will not complain about cast from char ** to char ** volatile).
If by first level, you mean the level after the outermost, that would
solve my issue, but I'm unsure if it provides the originally intended
warnings. On the other hand, there is also currently no warning for a
cast from char const ** to char const * const *. Maybe this was
likewise intended to be accepted as "regular qualifier adding".
If you mean in the context of the larger expression which dereferences
the outer pointer, this seems more clearly not dangerous, but glancing
through the code, I'm not sure if we have that context where the warning
is generated.
Ryan
More information about the Gcc
mailing list