Article View: borland.public.cppbuilder.nativeapi
Article #3763Re: What happens when ...
From: Alan Bellingham
Date: Sat, 06 May 2006 18:33
Date: Sat, 06 May 2006 18:33
24 lines
1612 bytes
1612 bytes
Michel Leunen <nospam@noreply.please> wrote:
>char* ptr = "XXX";
>
>is silently converted to:
>
>const char* ptr = "XXX";
>
>but it's perfectly legal code although deprecated.
It's more that it's silently converted to
char* ptr = const_cast<char*>("XXX");
as can be seen by the fact that you can assign through ptr. If you *do*
assign through ptr, then you're screwed, because you'll either get an
access violation, or a very difficult to find bug. But the compiler
won't stop you.
Alan Bellingham
--
Team Thai Kingdom
<url:http://www.borland.com/newsgroups/> Borland newsgroup descriptions
<url:http://www.borland.com/newsgroups/netiquette.html> netiquette
Technical Details
Message-ID:
<2sqp5250pk9jl07ti0p95fg62v3m4n22g7@4ax.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<445cbd5d$1@newsgroups.borland.com> <445cd44f$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,2f21d80b956d055f X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: Alan Bellingham <alanb@episys.com> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: What happens when ... Date: Sat, 06 May 2006 19:33:16 +0100 Reply-To: alanb@episys.com Message-ID: <2sqp5250pk9jl07ti0p95fg62v3m4n22g7@4ax.com> References: <445cbd5d$1@newsgroups.borland.com> <445cd44f$1@newsgroups.borland.com> X-Newsreader: Forte Agent 3.2/32.830 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 62.49.31.105 X-Trace: newsgroups.borland.com 1146940394 62.49.31.105 (6 May 2006 11:33:14 -0700) Lines: 24 Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail