From -1140899827333923337
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,fc6467e389022a2
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1994-02-10 18:05:20 PST
Newsgroups: comp.std.c++
Path: gmd.de!xlink.net!sol.ctr.columbia.edu!howland.reston.ans.net!europa.eng.gtefsd.com!library.ucla.edu!csulb.edu!paris.ics.uci.edu!news.claremont.edu!kaiwan.com!wetware!sjsumcs!horstman
From: horstman@sjsumcs.sjsu.edu (Cay Horstmann)
Subject: Re: Is char** to const char ** illegal?
Message-ID: <1994Feb11.020520.29112@sjsumcs.sjsu.edu>
Organization: San Jose State University - Math/CS Dept.
References: <1994Feb8.230934.18077@is.morgan.com>
Date: Fri, 11 Feb 1994 02:05:20 GMT
Lines: 33

In article <1994Feb8.230934.18077@is.morgan.com> jlieb@is.morgan.com (Jerry Liebelson) writes:
>Hi,
>  Does anyone know what the Standard says (or does not say) about the
>following conversion:
>
>        char *s;
>        const char** sp = &s;
>
>  CenterLine 2.0.4 does not report this conversion as being an error, but
>  Lucid 3.1 does.
>
>  Even though there is an additional level of indirection, why should
>  such usage be any less legal than
>
>		char *s;
>		const char *sp = s;		
>
>  The assignment is to a more restricted, safer (const-wise) pointer in
>both cases.
>
>-- 
An article in the C++ Report, about ten months ago, by Andrew Koenig,
explains this very clearly. I believe it is entitled "A const source of
confusion". The conversion char** -> const char** is illegal, char** ->
char* const* is legal (of course), and Andy argues that char** -> const char* 
const* should be legal as well. Confusing? Well, not all compiler manufacturers
get this straight either. I tried various versions of Borland, with conflicting
and incorrect results. 

Cay
horstman@cs.sjsu.edu




