From -2629758335859543699
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,fc6467e389022a2
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1994-02-08 16:09:38 PST
Path: gmd.de!newsserver.jvnc.net!nntpserver.pppl.gov!princeton!att-in!csn!col.hp.com!sdd.hp.com!spool.mu.edu!olivea!grapevine.lcs.mit.edu!matt
From: matt@x.org (Matt Landau)
Newsgroups: comp.std.c++
Subject: Re: Is char** to const char ** illegal?
Date: 9 Feb 94 00:09:38 GMT
Organization: X Consortium, Cambridge, Massachusetts
Lines: 33
Distribution: world
Message-ID: <matt.760752578@alex.x.org>
References: <1994Feb8.230934.18077@is.morgan.com>
NNTP-Posting-Host: alex.x.org

jlieb@is.morgan.com (Jerry Liebelson) writes:
>Does anyone know what the Standard says (or does not say) about the
>following conversion:
>
>        char *s;
>        const char** sp = &s;

char ** to const char ** is not a legal conversion.  Here's why:

    void foo () 
    {
        const char c = 'a';
        char *p = 0;
        char **pp = &p;         // points to p
        const char **pcp = pp;  // points to p, which is null
        *pcp = &c;              // makes p point to c
        *p = 'x';               // clobber c
    }

(Thanks to Scott Turner at Liant for the example.)

I believe if you think it through, you find that char ** converts safely
to const char * const *, rather than const char **.

>  CenterLine 2.0.4 does not report this conversion as being an error, but
>  Lucid 3.1 does.

Sounds like a bug in CenterLine's CC (or more probably in cfront).
-- 
 Matt Landau		    Technical Director, Application Toolkits
 matt@x.org		    The X Consortium, Inc.

 Waiting for a flash of enlightenment in all this blood and thunder.


