commit b377595b246be1de01c37f1d0269b5821e19b3fb
Author: Tor Didriksen <tor.didriksen@oracle.com>
Date:   Wed Apr 8 16:53:55 2015 +0200

    Bug#20768820 MAIN.BIGINT TEST FAILS WHEN BUILT WITH GCC 5 IN RELEASE BUILD
    
    Problem: with gcc5 in optmized mode, (- LLONG_MIN ) yields integer overflow.
    Fix: In ull2dec() change the loop which counts the number of decimal_digit_t's
    (cherry picked from mysql's commit b37d8bcc24f82f8e15c5f6e2243c8937af74acb7)

diff -up mariadb-10.0.17/strings/decimal.c.p11 mariadb-10.0.17/strings/decimal.c
--- mariadb-10.0.17/strings/decimal.c.p11	2015-04-10 13:17:48.944070201 +0200
+++ mariadb-10.0.17/strings/decimal.c	2015-04-10 13:22:27.062868618 +0200
@@ -997,7 +997,14 @@ static int ull2dec(ulonglong from, decim
 
   sanity(to);
 
-  for (intg1=1; from >= DIG_BASE; intg1++, from/=DIG_BASE) {}
+  if (from == 0)
+    intg1= 1;
+  else
+  {
+    /* Count the number of decimal_digit_t's we need. */
+    for (intg1= 0; from != 0; intg1++, from/= DIG_BASE)
+      ;
+  }
   if (unlikely(intg1 > to->len))
   {
     intg1=to->len;
