🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #1907

Re: string literals - lvalues ?

#1907
From: Alexsander Krotoff
Date: Tue, 05 Sep 1995 05:06
37 lines
1865 bytes
Steve Clamage (clamage@Eng.Sun.COM) wrote:
: krotoff@boy.rector.msu.su (Alexsander Krotoff) writes:

: >I have a questio: is it mentioned in the c++ draft standard are
: >string literals lvalues or not ? Is it possible to take an address
: >of string ?

: A string literal represents a null-terminated array of characters
: with static storage duration. When you write
: 	"abc"
: in an expression (except as the operand of sizeof), it is
: immediately converted to the address of the first char in the array
: which consists of 'a', 'b', 'c', '\0'.

: You cannot write &"abc", because that would be the address of an
: address, and has no meaning.

Thank you for respose.

The same rule is in the C, but in C it is legal to write:
char (*ca)[4] = &"abc";
since string is lvalue and the only requirement for `&' operand is
function designator or an lvalue that designates an object.
(ANSI C 3.3.3.2 "Address and indirection operators").

I am missing something ?
--
Alexander Krotoff				<krotoff@such.srcc.msu.su>
Research Computer Center			[Moscow]939-2638
Moscow State University				MGU, SRCC k316. GZ B-733r.


---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <MATT.95Sep04210628@Austern>
Path: arc1-ca.pugleaf.net!howland.reston.ans.net!agate!agate!Matt
References: <427hu8$2k8@alpha.phys.msu.su> <428qq7$jlp@engnews2.Eng.Sun.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!howland.reston.ans.net!agate!agate!Matt
From: krotoff@boy.rector.msu.su (Alexsander Krotoff)
Newsgroups: comp.std.c++
Subject: Re: string literals - lvalues ?
Date: 05 Sep 1995 05:06:28 GMT
Organization: Research Computer Center, Moscow State University
Approved: Matt@Austern
Message-ID: <MATT.95Sep04210628@Austern>
References: <427hu8$2k8@alpha.phys.msu.su> <428qq7$jlp@engnews2.Eng.Sun.COM>
Reply-To: krotoff@such.srcc.msu.su
NNTP-Posting-Host: austern.hip.berkeley.edu