Avoid -Wno-write-strings for k_standard.c [committed]
Chris Metcalf
cmetcalf@ezchip.com
Fri Feb 27 00:16:00 GMT 2015
On 2/26/2015 5:51 PM, Joseph Myers wrote:
> We want to avoid -Wno- options in makefiles as far as possible, by
> cleaning up the underlying issues if possible or failing that by using
> diagnostic pragmas. This patch eliminates the use of
> -Wno-write-strings for sysdeps/ieee754/k_standard.c by using casts in
> the source file to cast away const; those casts are encapsulated in a
> macro that also deals with the choice of strings for float / double /
> long double functions (for which the logic was previously replicated
> many times).
>
>
>
> +#define CSTR(func) ((char *) (type < 100 \
> + ? func \
> + : (type < 200 ? func "f" : func "l")))
> +
Nice cleanup.
It seems like this code would benefit from a comment as to why it makes
sense here to cast away const from a truly const string. It wasn't true in
the original either, but now the cast is further from the assignment to exc.name,
so it seems like it would be helpful now to document.
--
Chris Metcalf, EZChip Semiconductor
http://www.ezchip.com
More information about the Libc-alpha
mailing list