Is this a valid ANSI program?

David Tanguay datangua at watmath.waterloo.edu
Thu Jun 27 09:27:17 AEST 1991


In article <20461 at alice.att.com> ark at alice.UUCP () writes:
>The compiler is correct: you cannot convert char ** to const char ** .
>To see why, consider the following program fragment:
[...]
> Thus allowing the commented line
>would open a hole in the type system by allowing you to modify
>a "const char" object without an explicit cast.

const doesn't mean that the value won't change, it only means that you
can't change it through that handle. For example, const volatile int i is
a valid and meaningful declaration (e.g., a read-only clock).
The behaviour you want from const is similar to the noalias behaviour. 
-- 
David Tanguay                  datanguay at watmath.waterloo.edu
Thinkage, Ltd.                 dat at Thinkage.On.CA



More information about the Comp.lang.c mailing list