This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Questions about const.
- From: Ian Lance Taylor <ian at airs dot com>
- To: Ryan Lortie <desrt at desrt dot ca>
- Cc: gcc-help at gcc dot gnu dot org
- Date: 18 Jul 2005 23:22:01 -0700
- Subject: Re: Questions about const.
- References: <1121481285.1978.0.camel@moonpix.desrt.ca>
Ryan Lortie <desrt@desrt.ca> writes:
> GCC generates some warnings when doing type conversions in places that I
> don't believe the warnings are required. It'd be be cool if someone
> could explain it to me. I have an example program here:
>
> http://manic.desrt.ca/const.c
>
> I'm guessing that, by the C standard, arrays that contain items of
> different types are always considered incompatible and since 'char *'
> and 'const char *' are different types then 'const char **' and 'char
> **' are incompatible pointers. This just doesn't seem very useful when
> one of the base types is always safe to automatically promote to the
> other (in this case, char * -> const char *) and there is no chance that
> an unnoticed conversion could ever occur in the other direction without
> generating another warning/error.
As you say, this is from the C standard. gcc tries to follow the
standard.
Ian