[前][次][番号順一覧][スレッド一覧]

ruby-changes:53527

From: shyouhei <ko1@a...>
Date: Thu, 15 Nov 2018 18:03:10 +0900 (JST)
Subject: [ruby-changes:53527] shyouhei:r65743 (trunk): eval_error.c: log10(0) is ERANGE

shyouhei	2018-11-15 18:03:03 +0900 (Thu, 15 Nov 2018)

  New Revision: 65743

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65743

  Log:
    eval_error.c: log10(0) is ERANGE
    
    By definition, the logarithm of 0 is negative infinity.  This is a
    pole error (cf: cf: ISO/IEC 9899:1999 section 7.12.1 paragraph 3) and
    of course, cannot fit into an `int` value.  We have to resort to
    INT_MIN.

  Modified files:
    trunk/eval_error.c
Index: eval_error.c
===================================================================
--- eval_error.c	(revision 65742)
+++ eval_error.c	(revision 65743)
@@ -195,7 +195,7 @@ print_backtrace(const VALUE eclass, cons https://github.com/ruby/ruby/blob/trunk/eval_error.c#L195
 	long len = RARRAY_LEN(errat);
         int skip = eclass == rb_eSysStackError;
 	const int threshold = 1000000000;
-	int width = ((int)log10((double)(len > threshold ?
+        int width = (len <= 1) ? INT_MIN : ((int)log10((double)(len > threshold ?
 					 ((len - 1) / threshold) :
 					 len - 1)) +
 		     (len < threshold ? 0 : 9) + 1);

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]