This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap 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]

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!


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