This is the mail archive of the
mailing list for the GCC project.
Re: invalid conversion from typeX** to const typeX**
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Richard Baxter <richardbrucebaxter at gmail dot com>
- Cc: gcc-help <gcc-help at gcc dot gnu dot org>, "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Sat, 5 Dec 2015 13:01:01 +0000
- Subject: Re: invalid conversion from typeX** to const typeX**
- Authentication-results: sourceware.org; auth=none
- References: <CADT=pZMcTFs2KRejwCd2MsvZgqkykfUks4FXH6qpx5PyVUqdnA at mail dot gmail dot com>
On 5 December 2015 at 11:26, Richard Baxter wrote:
> Hi GCC dev team,
Hi, this is the wrong mailing list for questions seeking help using
GCC, please direct any follow-up to the gcc-help mailing list, thanks.
> I have developed software to parse C(++) code and automatically add
> const to function arguments (tracing all functions and their
> references). However, I have encountered an issue with the GCC/VS
> compilers preventing assignment of typeX** to const typeX**.
> Considering that const is being automatically added to the code after
> it is written, there is no danger of the situation occurring that is
> used to justify this limitation
> (http://c-faq.com/ansi/constmismatch.html). The const attribute is
> purely being used to enable programmers to know whether a variable is
> expected to be modified by the function (no checking of the
> problematic case above is required). I was wondering; is there any way
> of working around this design constraint?
In C++ you can add the const more thoroughly, changing X** to const X
* const *. I don't think that will help for C though.