This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: operator precedence differs from C language
On 03/31/2010 07:36 PM, Neo Liu wrote:
> I found that the operator precedence of "&" and "==" differed from C
> language. Take a look at the following statements.
That's not true -- in C and in stap, relational operators bind more
tightly than bitwise operators. http://tinyurl.com/9q6szp
Here's a program to convince yourself of this:
#include <stdio.h>
#define TEST(e) printf("( %s ) = %d\n", #e, e)
int main(int argc, const char *argv[])
{
if (argc < 2) return 1;
int x = atoi(argv[1]);
TEST(x);
TEST(x & 07);
TEST((x & 07) == 0);
TEST(x & (07 == 0));
TEST(x & 07 == 0);
return 0;
}
Josh