Article View: comp.std.c++
Article #1900Re: string literals - lvalues ?
From: Tom Payne
Date: Mon, 04 Sep 1995 15:36
Date: Mon, 04 Sep 1995 15:36
30 lines
1763 bytes
1763 bytes
Fergus Henderson (fjh@munta.cs.mu.OZ.AU) wrote:
: The doubt about whether or not &"abc" is legal is due to the fact
: that the draft C++ standard doesn't specify whether a string literal
: is an lvalue or not. Since the C standard does specify this - it
: specifies that a string literal *is* an lvalue - I would expect the
: eventual C++ standard to follow the C standard. &"abc" is legal C,
: and I expect it will be legal C++.
If "abc" isn't an lvalue, then sizeof("abc") is also illegal -- there
are no rvalues of type char-array, and array-to-pointer conversion is
supressed in this context, per 5.3.3:
4 The lvalue-to-rvalue, array-to-pointer, and
function-to-pointer standard conversions are
suppressed on the operand of sizeof.
Visibly, string literals must be lvalues for compatibility with C.
Tom Payne (thp@cs.ucr.edu)
[ 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:
<42dt53$189@galaxy.ucr.edu>Path:
arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamageReferences:
<427hu8$2k8@alpha.phys.msu.su> <428qq7$jlp@engnews2.Eng.Sun.COM> <9524518.21198@mulga.cs.mu.OZ.AU>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamage From: thp@cs.ucr.edu (Tom Payne) Newsgroups: comp.std.c++ Subject: Re: string literals - lvalues ? Date: 4 Sep 1995 15:36:35 GMT Organization: University of California, Riverside Department of Computer Science Approved: clamage@eng.sun.com (comp.std.c++) Message-ID: <42dt53$189@galaxy.ucr.edu> References: <427hu8$2k8@alpha.phys.msu.su> <428qq7$jlp@engnews2.Eng.Sun.COM> <9524518.21198@mulga.cs.mu.OZ.AU> NNTP-Posting-Host: taumet.eng.sun.com Content-Type: text X-Nntp-Posting-Host: corvette.ucr.edu X-Newsreader: TIN [version 1.2 PL2] Content-Length: 859 X-Lines: 26 Originator: clamage@taumet