This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: statement expressions and extended asm bug?


Nathan Sidwell wrote:
> inline int foo (int arg_)
> {
>   int result __asm("d0");
>   int arg __asm("d1"); // for sake of argument
> 
>   arg = arg_;
>   asm ("call whereever": "=r(result)" :"r(arg)" : ...);
> 
>   return result;
> }
> 
> This is subtly different from the statement expression form, because
> the result of a C statement expression can be an lvalue, whereas here
> it is an rvalue. (in g++, statement expressions always produce a result
> 'as-if' by 'return').

More to the point, calling the foo(arg) above from different function
arguments isn't a sequence-point violation, unlike calling the
statement-expressions.

    function(foo(arg1), foo(arg2));

could evaluate the two calls to foo() in either order, but it must
finish one completely before the other.

Perhaps this is a flaw in GCC's implementation of
statement-expression, because s-e is intended for use in macros
function-like macros -- whose callers don't know they are calling a
macro.

-- Jamie


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]