🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3949

Re: Placement of string literals

#3949
From: John Winters
Date: Thu, 07 Sep 1995 16:27
22 lines
1183 bytes
In article <1995Sep7.094751.4404@dcs.warwick.ac.uk>,
Zefram <A.Main@dcs.warwick.ac.uk> wrote:
>John Winters <john@polo.demon.co.uk> wrote:
>>Or indeed, as :
>>
>>const char __foo[] = {'H','e','l','l','o',' ','w','o','r','l','d','\0'};
>>char *foo;
>>const char *bar;
>>foo = (char *) __foo;
>>bar = (const char *) __foo;
>
>Indeed.  That's the effect of the const.
>

Not quite.  That's the effect of them being two identical string literals.
The compiler is entitled to coalesce the string literals
whether or not the things pointing to them are const.  (Or perhaps
you meant one of the later consts?)

John
-- 
John Winters.  Wallingford, Oxon, England.
Technical Details
Message-ID: <DEJn1p.A5o@polo.demon.co.uk>
Path: arc1-ca.pugleaf.net!dispatch.news.demon.net!demon!polo!john
References: <42c4uu$9e5@sparcserver.lrz-muenchen.de> <1995Sep4.123536.3152@dcs.warwick.ac.uk> <DEG3zz.66q@polo.demon.co.uk> <1995Sep7.094751.4404@dcs.warwick.ac.uk>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!dispatch.news.demon.net!demon!polo!john
From: john@polo.demon.co.uk (John Winters)
Newsgroups: comp.std.c
Subject: Re: Placement of string literals
Date: Thu, 7 Sep 1995 16:27:23 GMT
Organization: Wallingford
Message-ID: <DEJn1p.A5o@polo.demon.co.uk>
References: <42c4uu$9e5@sparcserver.lrz-muenchen.de> <1995Sep4.123536.3152@dcs.warwick.ac.uk> <DEG3zz.66q@polo.demon.co.uk> <1995Sep7.094751.4404@dcs.warwick.ac.uk>
Keywords: string literals, const
X-NNTP-Posting-Host: polo.demon.co.uk