Is this a valid ANSI program?
Stephen Clamage
steve at taumet.com
Fri Jun 28 01:08:24 AEST 1991
datangua at watmath.waterloo.edu (David Tanguay) writes:
|In article <609 at mtndew.Tustin.CA.US> friedl at mtndew.Tustin.CA.US (Stephen J. Friedl) writes:
|> void foo(const char **xxx) { }
|> main()
|> {
|> char **p = 0;
|> foo(p);
|> }
|>
|>The compiler claims that the argument /p/ to the function foo()
|>is incompatible with the prototype, and I just don't believe it.
|I don't believe it, either. In 3.3.16.1, Simple Assignment, Constraints:
| both operands are pointers to qualified or unqualified versions
| of compatible types, and the type pointed to by the left has all
| the qualifications of the type pointed to by the right
Sorry, you better believe it. The extract from the standard you quote
explains why! The two pointers are 'const char **xxx' and 'char **p'.
Parameter xxx points to a 'const char*', and variable p points to
a 'char *'. These types are not compatible, so the xxx and p are not
compatible.
--
Steve Clamage, TauMetric Corp, steve at taumet.com
More information about the Comp.lang.c
mailing list