g++-4.4 Ubuntu-Linux (32-Bit) ttmath-0.9.1, array index out of bounds
when i compile the current stable version samples on Ubuntu Linux with g++-4.4.1, i get the following warning:
g++ -c -Wall -pedantic -s -O2 -I.. big2.cpp
In file included from ../ttmath/ttmath.h:58,
from big2.cpp:1:
../ttmath/ttmathbig.h: In member function ťttmath::uint ttmath::Big<exp, man>::ToString_CreateNewMantissaAndExponent(string_type&
, const ttmath::Conv&, ttmath::Int<(exp + 1)>&) const [with string_type = std::basic_string<char,
std::char_traits<char>, std::allocator<char> >, char_type = char, unsigned int exp = 2u, unsigned
int man = 4u]Ť:
../ttmath/ttmathbig.h:2282: Warnung: array index in initializer exceeds array bounds
g++ -o big2 -Wall -pedantic -s -O2 -I.. big2.o
Best regards
Ettl Martin
This is a compiler issue, the condition is checked but the compiler doesn't see it. I'll change it in the next version.
Maybe we can report it to the gcc developers?
Can you simplify the it to a sample? I will report it to the gcc-developers.
Best regards
Martin
No, It is actually not a bug. First I check the exponent in this way:
if( exponent > maxbit + sint(int_size*TTMATH_BITS_PER_UINT) )
where exponent is ttmath::Int<> and then I cast it to sint:
sint how_many_bits = exponent.ToInt();
if( how_many_bits < 0 )
and the compiler doesn't know that the first 'if' is combined with the latter. I have to rewrite it in a simpler way.