M
Michael Ovetsky
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
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