* numeric.c (int_pow, fix_mul): Avoid optimization bugs of

clang.  Submitted by Wataru Kimura [Bug #6796].


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@36546 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
knu 2012-07-27 04:12:08 +00:00
parent 9de0a76ab2
commit 3b6affb067
2 changed files with 9 additions and 4 deletions

View file

@ -1,3 +1,8 @@
Fri Jul 27 13:04:31 2012 Akinori MUSHA <knu@iDaemons.org>
* numeric.c (int_pow, fix_mul): Avoid optimization bugs of
clang. Submitted by Wataru Kimura [Bug #6796].
Fri Jun 29 21:19:36 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> Fri Jun 29 21:19:36 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (stack_extend): prevent ALLOCA_N, which reserves a memory * eval.c (stack_extend): prevent ALLOCA_N, which reserves a memory

View file

@ -2162,7 +2162,7 @@ fix_mul(x, y)
VALUE x, y; VALUE x, y;
{ {
if (FIXNUM_P(y)) { if (FIXNUM_P(y)) {
#ifdef __HP_cc #if defined(__HP_cc) || defined(__clang__)
/* avoids an optimization bug of HP aC++/ANSI C B3910B A.06.05 [Jul 25 2005] */ /* avoids an optimization bug of HP aC++/ANSI C B3910B A.06.05 [Jul 25 2005] */
volatile volatile
#endif #endif
@ -2320,9 +2320,9 @@ int_pow(x, y)
y &= ~1; y &= ~1;
do { do {
while (y % 2 == 0) { while (y % 2 == 0) {
long x2 = x * x; volatile long x2 = x * x;
if (x2/x != x || !POSFIXABLE(x2)) { if (x2/x != x || !POSFIXABLE(x2)) {
VALUE v; volatile VALUE v;
bignum: bignum:
v = rb_big_pow(rb_int2big(x), LONG2NUM(y)); v = rb_big_pow(rb_int2big(x), LONG2NUM(y));
if (z != 1) v = rb_big_mul(rb_int2big(neg ? -z : z), v); if (z != 1) v = rb_big_mul(rb_int2big(neg ? -z : z), v);
@ -2332,7 +2332,7 @@ int_pow(x, y)
y >>= 1; y >>= 1;
} }
{ {
long xz = x * z; volatile long xz = x * z;
if (!POSFIXABLE(xz) || xz / x != z) { if (!POSFIXABLE(xz) || xz / x != z) {
goto bignum; goto bignum;
} }