This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: 'const' with double indirection
Jacob van der Woude writes:
> 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.
Not necessarily. We deliberately don't warn when passing a pointer to
a const-qualified version of a compatible type, presumably because it
would generate a ton of false positives. However, in your first
example this wasn't a const-qualified version of a compatible type,
but a pointer to an incompatible type.
> 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.
That's right.
> 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?
cdecl.
Andrew.