Is f() lvalue?
From: Michael Ovetsky (movetsky_at_ureach.com)
Date: 10/31/04
- Next message: Alex Drummond: "Re: C++ sucks for games"
- Previous message: Phlip: "Re: Address of temporary objects"
- Next in thread: marco.wahl_at_gmail.com: "Re: Is f() lvalue?"
- Reply: marco.wahl_at_gmail.com: "Re: Is f() lvalue?"
- Reply: Andrey Tarasevich: "Re: Is f() lvalue?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 31 Oct 2004 14:29:14 +0000 (UTC)
Consider:
int g(){int b=1; return b;}
int main()
{
int d=2;
g()=d;
}
gcc compiler fails to compile it with 'non-lvalue in assignment' error
message, which I would expect.
However the following code happily compiles and executes:
struct A {int a;};
A f(){A b={1}; return b;}
int main()
{
A c ={2};
f()=c;
}
Does it mean that f() is lvalue if f returns struct or class object, but
not lvalue if f returns built-in type or incorrect implementation of
C++ standard by gcc is one to blame?
Thanks,
Michael
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
- Next message: Alex Drummond: "Re: C++ sucks for games"
- Previous message: Phlip: "Re: Address of temporary objects"
- Next in thread: marco.wahl_at_gmail.com: "Re: Is f() lvalue?"
- Reply: marco.wahl_at_gmail.com: "Re: Is f() lvalue?"
- Reply: Andrey Tarasevich: "Re: Is f() lvalue?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|