This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: 'const' with double indirection
- From: "Jacob van der Woude" <jacobw at allieddata dot nl>
- To: <gcc-help at gcc dot gnu dot org>
- Date: Thu, 12 Apr 2007 15:43:38 +0200
- Subject: RE: 'const' with double indirection
Thanks for the answer, Andrew.
But if we simple use your quoted part of the standard on the following
snippet:
void g1(const int * const List) {
} /* g1 */
void f1(int * const List) {
g1(List);
} /* f1 */
void g2(const int * List) {
} /* g2 */
void f2(int * List) {
g2(List);
} /* f2 */
there also should be a warning with each call of g.
But there is no warning.
And there is no need for the warning (in both cases).
You can't fiddle with the arguments to direct or indirect modify the
original constants.
With double (or more) level of indirection there is, except if everything is
'const'.
So what is de difference with single or double indirection in respect to the
(not) generated warnings?
If you want me to discuss this on a C mailing list fiest, can you give me
the name of one?
With what (tool?) did you generate they explanations of declarions?
Jacob.
-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org]On
Behalf Of Andrew Haley
Sent: Thursday, 12 April, 2007 14:05
To: Jacob van der Woude
Cc: gcc-help@gcc.gnu.org
Subject: Re: 'const' with double indirection
Jacob van der Woude writes:
> I'm not sure if the following is a compiler issue or a language/standard
> misunderstandig my side.
> (And I hope that in general this all is understood, English is not my
native
> language.)
cdecl> explain const int * const * const List
declare List as const pointer to const pointer to const int
cdecl> explain int * const * const List
declare List as const pointer to const pointer to int
So the question is whether these types are compatible. This can
easily be answered by reference to the standard:
6.7.3 Para 9: "For two qualified types to be compatible, both shall
have the identically qualified version of a compatible type; the order
of type qualifiers ... does not affect the specified type."
Andrew.