Issue #5693 has been updated by mrkn (Kenta Murata).

Status changed from Assigned to Closed

This is fixed by r33915
----------------------------------------
Bug #5693:  clang warning in bigdecimal
https://bugs.ruby-lang.org/issues/5693#change-26943

Author: drbrain (Eric Hodel)
Status: Closed
Priority: Normal
Assignee: mrkn (Kenta Murata)
Category: ext
Target version: 
ruby -v: -


When bigdecimal is compiled under clang I get this warning:

/Users/drbrain/Work/svn/ruby/trunk/ext/bigdecimal
compiling bigdecimal.c
bigdecimal.c:4364:37: warning: array index of '1' indexes past the end of an
     array (that contains 1 elements) [-Warray-bounds]
       b1b2p1 = b1b2 = b1 * BASE + b->frac[1];
                                   ^       ~
./bigdecimal.h:147:5: note: array 'frac' declared here
   BDIGIT frac[1]; /* Pointer to array of fraction part.       */
   ^
../.././include/ruby/defines.h:93:17: note: instantiated from:
# define BDIGIT unsigned int
               ^
1 warning generated.
linking shared-object bigdecimal.bundle
installing default bigdecimal libraries

Paste of warning in case spacing is munged: http://paste.segment7.net/or.html

I'm using Apple clang 3.0:

$ clang -v
Apple clang version 3.0 (tags/Apple/clang-211.10.1) (based on LLVM 3.0svn)
Target: x86_64-apple-darwin11.2.0
Thread model: posix

I dug around in the bigdecimal and it seems that frac is modified to point to a larger array, but perhaps clang has detected a scenario where it is not modified?


-- 
http://bugs.ruby-lang.org/