I
Ian Zimmerman
Hello, I hate to make a fool of myself, but:
in C99, is
var = ((exp1) || (exp2));
necessarily equivalent to
int temp = (exp1); var = (temp != 0 ? temp : (exp2));
as I believe it was in pre-99 C? gcc seems to compile it rather as
var = ((exp1) != 0 || (exp2) != 0)
ie. the final value of var is always 0 or 1.
If this latter translation is indeed correct, can anyone think of
a way to achieve the old effect without a temporary variable?
This code needs to go into a macro, and exp1 and exp2 are potentially
complex expressions involving function calls and side effects.
in C99, is
var = ((exp1) || (exp2));
necessarily equivalent to
int temp = (exp1); var = (temp != 0 ? temp : (exp2));
as I believe it was in pre-99 C? gcc seems to compile it rather as
var = ((exp1) != 0 || (exp2) != 0)
ie. the final value of var is always 0 or 1.
If this latter translation is indeed correct, can anyone think of
a way to achieve the old effect without a temporary variable?
This code needs to go into a macro, and exp1 and exp2 are potentially
complex expressions involving function calls and side effects.