From dbda7f4921f8ddee42e2de9a7ed5fbc60a8dbab8 Mon Sep 17 00:00:00 2001 From: Raymond Lu Date: Wed, 31 Aug 2011 15:00:49 -0500 Subject: [svn-r21342] Issue 7674 - clang compiler with -fcatch-undefined-behavior -ftrapv discovered several problems in the test suite. One of them is in the INIT_INTEGER macro definition in dt_arith.c. It complained about line 150 where it tried to subtract 1 from the negative minimal value of "int", causing it to overflow (or underflow). So I revised the code to avoid it. Tested on jam, koala, linew, and Mac OS Lion with CLANG compiler. --- test/dt_arith.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/test/dt_arith.c b/test/dt_arith.c index 078242d..054f069 100644 --- a/test/dt_arith.c +++ b/test/dt_arith.c @@ -121,7 +121,7 @@ static int without_hardware_g = 0; TYPE value2 = 0; \ \ /* Allocate buffers */ \ - NELMTS=(SRC_PREC-1)*3+1; \ + NELMTS=SRC_PREC*3; \ BUF = (unsigned char*)aligned_malloc(NELMTS*MAX(SRC_SIZE, DST_SIZE)); \ SAVED = (unsigned char*)aligned_malloc(NELMTS*MAX(SRC_SIZE, DST_SIZE)); \ HDmemset(BUF, 0, NELMTS*MAX(SRC_SIZE, DST_SIZE)); \ @@ -132,7 +132,7 @@ static int without_hardware_g = 0; \ /*positive values, ascending order. VALUE1 starts from 00000001, to 00000010, until 10000000*/ \ /*VALUE2 ascends from 00000000, to 00000011, 00000111,..., until 11111111.*/ \ - for(n=0; n=SRC_MIN) { \ memcpy(buf_p, &value1, SRC_SIZE); \ memcpy(saved_p, &value1, SRC_SIZE); \ @@ -146,20 +146,26 @@ static int without_hardware_g = 0; saved_p += SRC_SIZE; \ } \ \ - value1 <<= 1; \ - value2 = (value1 - 1) | value1; \ + if(n=SRC_MIN) { \ memcpy(buf_p, &value2, SRC_SIZE); \ memcpy(saved_p, &value2, SRC_SIZE); \ buf_p += SRC_SIZE; \ saved_p += SRC_SIZE; \ } \ - value2 <<= 1; \ + if(n