M
Matt Priest
Hello All,
I have encountered a difference between compilers and need some help
understanding what is happening.
I have a function such as:
void MyClass::foo(GenericType& myarg){...}
when I call it such as:
main()
{
MyClass myObject;
..
..
..
myObject.foo( <C/C++ expression evaluating to a GenericType>);
}
It compiles and executes fine with one compiler (Sun Forte) but won't in
another
compiler (g++) unless I do the following:
(The compile error is that the argument needs to be an lvalue.....)
main()
{
MyClass myObject;
GenericType myTemp;
..
..
..
myTemp=<C/C++ expression evaluating to an object of type MyClass>
myObject.foo( myTemp);
}
Shouldn't the compiler track the results from the expression, along with
the appropriate lvalue nature of the return value, in the stack space
for that particular scope?
What exactly is this issue? A style/preference or a hint at some
programming error likely to cause some problem in the future?
Matt
I have encountered a difference between compilers and need some help
understanding what is happening.
I have a function such as:
void MyClass::foo(GenericType& myarg){...}
when I call it such as:
main()
{
MyClass myObject;
..
..
..
myObject.foo( <C/C++ expression evaluating to a GenericType>);
}
It compiles and executes fine with one compiler (Sun Forte) but won't in
another
compiler (g++) unless I do the following:
(The compile error is that the argument needs to be an lvalue.....)
main()
{
MyClass myObject;
GenericType myTemp;
..
..
..
myTemp=<C/C++ expression evaluating to an object of type MyClass>
myObject.foo( myTemp);
}
Shouldn't the compiler track the results from the expression, along with
the appropriate lvalue nature of the return value, in the stack space
for that particular scope?
What exactly is this issue? A style/preference or a hint at some
programming error likely to cause some problem in the future?
Matt