Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!sdd.hp.com!uakari.primate.wisc.edu!samsung!uunet!taumet!steve From: steve@taumet.com (Stephen Clamage) Newsgroups: comp.lang.c Subject: Re: Is this a valid ANSI program? Message-ID: <784@taumet.com> Date: 27 Jun 91 15:08:24 GMT References: <609@mtndew.Tustin.CA.US> <1991Jun26.232121.29755@watmath.waterloo.edu> Organization: Taumetric Corporation, San Diego Lines: 27 datangua@watmath.waterloo.edu (David Tanguay) writes: |In article <609@mtndew.Tustin.CA.US> friedl@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@taumet.com