This is the mail archive of the
mailing list for the GCC project.
[website, changes] (was: Re: warning about const multidimensional array as function parameter)
- From: Martin Uecker <uecker at eecs dot berkeley dot edu>
- To: Manuel LÃpez-IbÃÃez <lopezibanez at gmail dot com>
- Cc: gcc Mailing List <gcc at gcc dot gnu dot org>
- Date: Mon, 26 Jan 2015 10:15:19 -0800
- Subject: [website, changes] (was: Re: warning about const multidimensional array as function parameter)
- Authentication-results: sourceware.org; auth=none
- References: <CAESRpQC0=QFaDNrs2YmzcRHfDw_iiKKwJCLQT=p0Un_ph_=+=A at mail dot gmail dot com> <20141013160138 dot 3a3b0c06 at lemur> <CAH6eHdSF5tVhfsFq8OV_ysYfovh17hJSVLQeLvEWsnAn8N+xgQ at mail dot gmail dot com> <20141013161226 dot 623681c2 at lemur> <CAESRpQACK2U1A_i8xBaxrxACDkS9zsV2rcF86upLx2PFyDsPLQ at mail dot gmail dot com>
Manuel LÃpez-IbÃÃez <firstname.lastname@example.org>:
> On 14 October 2014 01:12, Martin Uecker <email@example.com> wrote:
> > Converting a pointer to an array to a pointer to a constant array
> > is safe. Converting a pointer to a pointer to a pointer to a pointer
> > to a constant is not (as the CFAQ points out).
> You are probably right that it is safe. Unfortunately, C considers
> invalid cases that are safe and that are allowed by C++ (as mentioned
> in that C FAQ). I updated the FAQ with comments by Joseph Myers taken
> from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47143 and
Since my patch to change this has been accepted, could you please
update the FAQ again?
I would suggest to change the paragraph starting with
"You are passing.." to:
"You are passing int (*) to const int (*), which is not correct
according to the C standard. You can disable the warning with
-Wno-incompatible-pointer-types. Starting with version 5, gcc
only warns about this when using '-pedantic'."
And then I would suggest to simply remove everything afterwards
because it refers to pointers-to-pointers and not pointers-to-arrays.
Also, I think the change could be mentioned here:
"gcc will not warn about incompatible pointers types anymore when passing a
pointer to an array as a pointer to a constant array or vice versa (except
when using '-pedantic'). Instead,it will emit a new warning only if the
'const' qualifier is lost (see '-Wno-discarded-array-qualifiers')."