Manuel López-Ibáñez <lopeziba...@gmail.com>:

> On 14 October 2014 01:12, Martin Uecker <uec...@eecs.berkeley.edu> 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
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=33076.

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 (*)[3] to const int (*)[3], 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:

https://gcc.gnu.org/gcc-5/changes.html

Suggested text:

"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')."

Cheers,
Martin




Reply via email to