This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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]

[Bug libstdc++/47913] New: [C++0x] improve ratio_add to overflow less often


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47913

           Summary: [C++0x] improve ratio_add to overflow less often
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: marc.glisse@normalesup.org


ratio_add currently computes something like:
gcd=gcd(den1,den2)
num=num1*(den2/gcd)+num2*(den1/gcd)
den=den1*(den2/gcd)
gcd2=gcd(num,den)
num/=gcd2
den/=gcd2

In cases where gcd2 is not 1, the computation may overflow whereas the final
result would fit. Even without that, it is possible that one or both of the
terms added in num are too large but their sum is not.

As a quality of implementation issue, it would be nice to reduce those cases a
bit. But that comes far far behind the ratio_less improvement described in PR
42622.


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