This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: -Wcast-qual and casting away
Richard Guenther <richard.guenther@gmail.com> writes:
> For
>
> extern const char **f1();
> void f(char *p)
> {
> *(char **)f1() = p;
> }
>
> it warns with
>
> t.C: In function âvoid f(char*)â:
> t.C:4: warning: cast from type âconst char**â to type âchar**â casts
> away constness
>
> which makes sense.
This is actually a safe operation, you can even store safely into
**(char **)f1() afterwards.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."