From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24832 invoked by alias); 1 Apr 2010 16:30:20 -0000 Received: (qmail 24814 invoked by uid 22791); 1 Apr 2010 16:30:19 -0000 X-SWARE-Spam-Status: No, hits=-6.8 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_XF,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 01 Apr 2010 16:30:16 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o31DMu1R008569 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 1 Apr 2010 09:22:56 -0400 Received: from fche.csb (vpn-235-68.phx2.redhat.com [10.3.235.68]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o31DMtIo025459; Thu, 1 Apr 2010 09:22:56 -0400 Received: by fche.csb (Postfix, from userid 2569) id 21B5A58123; Thu, 1 Apr 2010 09:22:54 -0400 (EDT) To: Neo Liu Cc: SystemTap Subject: Re: operator precedence differs from C language References: From: fche@redhat.com (Frank Ch. Eigler) Date: Thu, 01 Apr 2010 16:30:00 -0000 In-Reply-To: (Neo Liu's message of "Thu, 1 Apr 2010 10:36:54 +0800") Message-ID: User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org X-SW-Source: 2010-q2/txt/msg00004.txt.bz2 Neo Liu writes: > I found that the operator precedence of "&" and "==" differed from C > language. Take a look at the following statements. > if ($flags & 07 == 0) { ... } Actually, I think we do it the same way C does. Comparison operators such as "==" have higher precedence. % cat foo.c int main () { printf("%d\n", 0xf0 & 0xff == 0); } % cat foo.stp probe begin {printf("%d\n", 0xf0 & 0xff == 0); exit()} Both these print 0 for == or !=. - FChE