Bug 65612

Summary: wrong results from __moddi3
Product: [Retired] Red Hat Linux Reporter: Radu Greab <radu>
Component: glibcAssignee: Jakub Jelinek <jakub>
Status: CLOSED ERRATA QA Contact: Brian Brock <bbrock>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.3CC: fweimer, hui.huang, will.smith
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2002-09-19 21:27:26 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Test code
none
Proposed patch none

Description Radu Greab 2002-05-28 15:55:41 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.9) Gecko/20020513

Description of problem:
If modulo operands are long long int, thus __moddi3 is used, and the second
argument of modulo is negative, then the result has the opposite sign then the
correct one.


Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1. Compile the test code as usual: "gcc -Wall t1.c". __moddi3 from libgcc is
used and you get the right results.
2. Compile the test code but force it to use __moddi3 from glibc: "gcc -Wall -lc
t1.c". You get the wrong results.


Actual Results:
  3 %  10 =   3
  3 % -10 =  -3
 -3 %  10 =  -3
 -3 % -10 =   3


Expected Results:
  3 %  10 =   3
  3 % -10 =   3
 -3 %  10 =  -3
 -3 % -10 =  -3


Additional info:

Comment 1 Radu Greab 2002-05-28 15:56:42 UTC
Created attachment 58767 [details]
Test code

Comment 2 Radu Greab 2002-05-28 15:58:09 UTC
Created attachment 58768 [details]
Proposed patch

Comment 3 Hui Huang 2002-09-19 21:27:20 UTC
Any plan to fix this in the near future? Java "longs" are "long longs"
on x86. This bug is definitely having a big impact on us.

Comment 4 Jakub Jelinek 2002-09-19 21:35:02 UTC
http://rhn.redhat.com/errata/RHBA-2002-116.html obsoleted by 2 security erratas
in the mean time.