This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: warning about const multidimensional array as function parameter
- From: Manuel López-Ibáñez <lopezibanez at gmail dot com>
- To: Martin Uecker <uecker at eecs dot berkeley dot edu>
- Cc: Jonathan Wakely <jwakely dot gcc at gmail dot com>, gcc Mailing List <gcc at gcc dot gnu dot org>, "Joseph S. Myers" <joseph at codesourcery dot com>
- Date: Tue, 14 Oct 2014 03:51:41 +0200
- Subject: 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>
On 14 October 2014 01:12, Martin Uecker <uecker@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.
I'm not sure how much effort would be to make the C FE of GCC follow
the rules of C++ or whether this would conflict with other parts of
the standard (that is, rejecting valid C programs).
Perhaps the option could be separated into two, one only enabled by
-Wpedantic that controls cases that are known to be safe
(-Wpedantic-incompatible-pointer-types? -Wincompatible-but-safe?).
Still, someone would need to step up and do the work:
https://gcc.gnu.org/wiki/GettingStarted#Basics:_Contributing_to_GCC_in_10_easy_steps
Cheers,
Manuel.