This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
operator precedence differs from C language
- From: Neo Liu <diabloneo at gmail dot com>
- To: SystemTap <systemtap at sourceware dot org>
- Date: Thu, 1 Apr 2010 10:36:54 +0800
- Subject: operator precedence differs from C language
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!