operator precedence differs from C language
Neo Liu
diabloneo@gmail.com
Thu Apr 1 02:37:00 GMT 2010
I found that the operator precedence of "&" and "==" differed from C
language. Take a look at the following statements.
if ($flags & 07 == 0) { ... }
I thought this statement would first calculate ($flags & 07)
and then calculate (($flags & 07) == 0), but the it is not the case.
It first calculates (07 == 0) and then ($flags & (07 == 0)),
so the result is 0 but not the expected 1. As a solution, I wrote the
statement as:
if (($flags & 07) == 0) { ... }
to get the computing order I want
Is this the stap language feature, or should I report this as a bug?
Thanks!
More information about the Systemtap
mailing list