This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Strange const warning


Ian Lance Taylor wrote:
> 
> This is a generic C question, not a question specific to gcc.
> 
> The reason is that when arrays are passed as parameters, they decay to
> pointers.  The effect is that the const qualifer does not work as you
> expect it to.

Thanks for the replies, you are right the function is being treated
something like:
	void test(int (*a)[1])

What's slightly strange is that if I make the array in main() const it
compiles without the warning.

Obviously removing the const in the test() argument is ok, it's a pity
you can't mark a multi-dimensional array parameter as const, it's just
part of the leagacy of C's pointer/array loose definition.

Jon


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]