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

Re: exp/1978: >> operator uses sign of right-hand operand


The following reply was made to PR exp/1978; it has been noted by GNATS.

From: Ramana Radhakrishnan <ramana.radhakrishnan@codito.com>
To: gdb-prs@sources.redhat.com, johnboy@moriancumer.net,
        nobody@sources.redhat.com, gdb-gnats@sources.redhat.com
Cc:  
Subject: Re: exp/1978: >> operator uses sign of right-hand operand
Date: Wed, 10 Aug 2005 20:08:15 +0530

 http://sources.redhat.com/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gdb&pr=1978
 
 >From the C standard.  Look at 6.5.7 Bitwise Shift operations. 
 
 5. The result of E1 >> E2 is E1 right-shifted E2 bit positions. If E1
 has an unsigned type
 or if E1 has a signed type and a nonnegative value, the value of the
 result is the integral
 part of the quotient of E1 / 2E2. If E1 has a signed type and a negative
 value, the
 resulting value is implementation-defined.
 
 Also your understanding that GDB does not distinguish the cases is
 correct. Look out for unsigned_operation in valarith.c : value_binop.  
 
 In the case where you claim a discrepancy the resulting value is
 implementation defined. I am however not sure whether GCC and GDB match
 always in all their expression evaluations or what the policy is.  Hence
 my reading is that GDB although it is doing something different from
 what GCC does , is still doing the right thing. 
 
 Following this up on gdb@
 
 cheers
 Ramana
 
 
 -- 
 Ramana Radhakrishnan
 GNU Tools
 codito ergo sum (www.codito.com)
 


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