On 5/24/23 15:09, Richard W.M. Jones wrote:
> On Wed, May 24, 2023 at 07:39:20AM +0200, Laszlo Ersek wrote:
>> Going through the changes individually, it seems like we could eliminate
>> a handful of the casts altogether; for examle (char *)"string literal"
>> ones.
> 
> It'd be interesting to remove then and compile with
> './configure --enable-gcc-warnings' to see if that creates new
> warnings.
> 
>> (The C standard effectively says that a (non-wide) string literal
>> has type "static char[n]", not "static const char[n]".) But that
>> would be a different patch, plus I can imagine we have those casts
>> in the first place because gcc complained or whatever. :)
> 
> It's a bit surprising.  Surely any string literal is placed in the
> text section so definitely not writable?

The standard does say that any attempt to modify a string literal leads
to undefined behavior. But the type of a non-wide string literal is
still "array of chars".

Laszlo

_______________________________________________
Libguestfs mailing list
Libguestfs@redhat.com
https://listman.redhat.com/mailman/listinfo/libguestfs

Reply via email to