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] [C++0x] improve ratio_add to overflow less often


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

--- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-03-01 23:00:05 UTC ---
Thanks again for your help on this.

Preliminarily, a few observations: 1- Please make sure the code is minimally
documented (are the comments in longlong.h enough?); 2- I see stuff like
__builtin_clzll(__d) on __d a uintmax_t, I'm not sure it's always ok, on any
32-bit and 64-bit target. More generally - I'm asking to Marc the mathematician
here, not Mark the libstdc++ contributor - do we have a clear characterization
of which specific overflows can be avoided? Are we *really* sure the
boost::rational implementation is equivalent to GCC and weaker than what you
are proposing: the first time I looked into it I remember seeing a
normalization happening earlier toward the end, per the last two lines of that
comment:

 // Which proves that instead of normalizing the result, it is better to
 // divide num and den by gcd((a*d1 + c*b1), g)


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