Article View: gnu.g++.bug
Article #237Error "references are not lvalues"?
From: Jason Merrill
Date: Sun, 12 Apr 1992 06:32
Date: Sun, 12 Apr 1992 06:32
39 lines
1503 bytes
1503 bytes
This code:
class SubString : public NIHCL {
char* sp; // substring pointer
unsigned sl; // substring length
String* st; // String this is a SubString of
...
}
...
inline SubString::SubString(const String& s, unsigned pos, unsigned lgt)
{
sp = &((String&)s).p[pos];
sl = lgt;
st = &(String&)s;
checkSubStr();
}
...
generates the error
String.h: In method `SubString::SubString (const class String&, unsigned
int, unsigned int)':
In file included from Class.c:37:
String.h:227: references are not lvalues
I assume that this error comes from trying to take the address of s cast to
a String&. This seems perfectly proper to me (and to Borland C++ 3.0);
since s is a reference type already, &(String&)s should return a String*
pointing to s.
What logic are you using to say that references are not lvalues? The fact
that references ARE lvalues is the reason for returning type& from a
function rather than just type&. I really don't understand the reasoning
behind this error.
--
Jason Merrill
jason@jarthur.claremont.edu
Technical Details
Message-ID:
<1992Apr12.063249.16069@muddcs.claremont.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!jarthur.claremont.edu!jasonShow Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!jarthur.claremont.edu!jason From: jason@jarthur.claremont.edu (Jason Merrill) Subject: Error "references are not lvalues"? Message-ID: <1992Apr12.063249.16069@muddcs.claremont.edu> Sender: gnulists@ai.mit.edu Organization: Harvey Mudd College Distribution: gnu Date: Sun, 12 Apr 1992 06:32:49 GMT Approved: bug-g++@prep.ai.mit.edu Lines: 40