-Wcast-qual consistency with initialization conversion and double pointer types
Martin Uecker
muecker@gwdg.de
Mon Jun 17 13:22:08 GMT 2024
Am Montag, dem 17.06.2024 um 12:06 +0000 schrieb Joseph Myers:
> On Sun, 16 Jun 2024, Martin Uecker via Gcc 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 would guess it looks at all qualifiers added at
> > all level but should ignore the one on the first level.
>
> This is meant to be implementing, as an extension to C, the C++ rules
> (where converting from char** to const char** is unsafe, but converting
> from char** to const char*const* is safe). So the first question is what
> C++ thinks of this conversion.
>
Note that this is about the case where no third-level qualifier
is added. We should still warn about converting from char** to
const char **, and to volatile char ** but probably not (I think)
when converting to char*const*, const char*const*,
volatile char*const*, and also not when converting
to char*volatile*. So not when all intermediate casts
are const but also not when only a qualifier is added
to the second level but not to deeper levels.
Martin
More information about the Gcc
mailing list