[Bug c/33076] Warning when passing a pointer to a const array to a function that expects a pointer to a non-cast one
joseph at codesourcery dot com
gcc-bugzilla@gcc.gnu.org
Wed Sep 26 12:43:00 GMT 2007
------- Comment #9 from joseph at codesourcery dot com 2007-09-26 12:42 -------
Subject: Re: Warning when passing a pointer to a const array
to a function that expects a pointer to a non-cast one
On Wed, 26 Sep 2007, jozef dot behran at krs dot sk wrote:
> And another point: Whether C/C++ have or don't have qualified array types,
> still the difference between the "const caca *" and "caca *" types is a "const"
> qualifier being applied to some part of the "caca *" base type. Therefore the
> types must be compatible when the automatic type conversion involved only adds
> "const" qualifiers to the type. Therefore the warnings are not legitimate.
Read the C FAQ. You can't pass a "char **" where a "const char **" is
expected either in C. That's how the language works.
http://c-faq.com/ansi/constmismatch.html
C++ allows certain cases C doesn't that can be shown to be safe, as noted
in that FAQ. A proposal to make C use the C++ rules was rejected in the
course of C99 development.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33076
More information about the Gcc-bugs
mailing list