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: Warning when using const pointer to fixed size array


Hi Aaron,

> void foo(const int (* p)[9]);
> 
> In this case, you are guaranteed that the caller is giving you a valid
> buffer. Otherwise, you will get a compile error message which will help
> you quickly detect a problem.

I think...

In C, arrays degenerate into pointers at the drop of a hat.

These two kinds of pointers are compatible:
int* p;
int const* p;

The two kinds of pointers are compatible:
int** p;
int* const* p;

The two kinds of pointers are not compatible:
int** p;
int const** p;

Your situation is like the third case.  The const is not
two-levels-of-indirection compatible.

Anyone have ISO 9899 on hand to cite chapter & verse?

HTH,
--Eljay


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