this patch fixes all warnings from g++-4.5 on Ubuntu Linux from file: ttmathunint.h:

../srcext/ttmath/ttmath/ttmathuint.h: In member function ttmath::uint ttmath::UInt<value_size>::CompensationToLeft():
../srcext/ttmath/ttmath/ttmathuint.h:591:48: warning: suggest a space before ; or explicit braces around empty body in for statement
../srcext/ttmath/ttmath/ttmathuint.h: In member function bool ttmath::UInt<value_size>::FindLeadingBit(ttmath::uint& , ttmath::uint&) const:
../srcext/ttmath/ttmath/ttmathuint.h:638:69: warning: suggest a space before ; or explicit braces around empty body in for statement
../srcext/ttmath/ttmath/ttmathuint.h: In member function bool ttmath::UInt<value_size>::FindLowestBit(ttmath::uint& , ttmath::uint&) const:
../srcext/ttmath/ttmath/ttmathuint.h:670:66: warning: suggest a space before ; or explicit braces around empty body in for statement
../srcext/ttmath/ttmath/ttmathuint.h: In member function void ttmath::UInt<value_size>::MulInt(ttmath::uint, ttmath::UInt<result_size>&) const:
../srcext/ttmath/ttmath/ttmathuint.h:881:63: warning: suggest a space before ; or explicit braces around empty body in for statement
../srcext/ttmath/ttmath/ttmathuint.h:889:60: warning: suggest a space before ; or explicit braces around empty body in for statement
../srcext/ttmath/ttmath/ttmathuint.h: In member function void ttmath::UInt<value_size>::Mul2Big2(const ttmath::uint*, const ttmath::uint*, ttmath::UInt<(ss_size * 2)>&):
../srcext/ttmath/ttmath/ttmathuint.h:1103:58: warning: suggest a space before ; or explicit braces around empty body in for statement
../srcext/ttmath/ttmath/ttmathuint.h:1104:58: warning: suggest a space before ; or explicit braces around empty body in for statement
../srcext/ttmath/ttmath/ttmathuint.h:1106:58: warning: suggest a space before ; or explicit braces around empty body in for statement
../srcext/ttmath/ttmath/ttmathuint.h:1107:58: warning: suggest a space before ; or explicit braces around empty body in for statement
../srcext/ttmath/ttmath/ttmathuint.h: In member function void ttmath::UInt<value_size>::MulFastestBig(const ttmath::UInt<value_size>&, ttmath::UInt<(value_size * 2)>&):
../srcext/ttmath/ttmath/ttmathuint.h:1429:62: warning: suggest a space before ; or explicit braces around empty body in for statement
../srcext/ttmath/ttmath/ttmathuint.h:1430:66: warning: suggest a space before ; or explicit braces around empty body in for statement
../srcext/ttmath/ttmath/ttmathuint.h:1439:59: warning: suggest a space before ; or explicit braces around empty body in for statement
../srcext/ttmath/ttmath/ttmathuint.h:1440:63: warning: suggest a space before ; or explicit braces around empty body in for statement
../srcext/ttmath/ttmath/ttmathuint.h: In member function ttmath::uint ttmath::UInt<value_size>::DivInt(ttmath::uint, ttmath::uint*):
../srcext/ttmath/ttmath/ttmathuint.h:1502:56: warning: suggest a space before ; or explicit braces around empty body in for statement
../srcext/ttmath/ttmath/ttmathuint.h: In member function ttmath::uint ttmath::UInt<value_size>::Div_CalculatingSize(const ttmath::UInt<value_size>&, ttmath::uint&, ttmath::uint&):
../srcext/ttmath/ttmath/ttmathuint.h:1622:36: warning: suggest a space before ; or explicit braces around empty body in for statement
../srcext/ttmath/ttmath/ttmathuint.h:1627:34: warning: suggest a space before ; or explicit braces around empty body in for statement
../srcext/ttmath/ttmath/ttmathuint.h:1638:49: warning: suggest a space before ; or explicit braces around empty body in for statement
../srcext/ttmath/ttmath/ttmathuint.h: In member function bool ttmath::UInt<value_size>::Div2_DivisorGreaterOrEqual(c onst ttmath::UInt<value_size>&, ttmath::UInt<value_size>*, ttmath::uint, ttmath::uint, ttmath::uint):
../srcext/ttmath/ttmath/ttmathuint.h:1923:62: warning: suggest a space before ; or explicit braces around empty body in for statement

Here is the patch:

Index: ttmathuint.h
============================================================ =======
--- ttmathuint.h (Revision 303)
+++ ttmathuint.h (Arbeitskopie)
@@ -588,7 +588,7 @@

// a - index a last word which is different from zero
sint a;
- for(a=value_size-1 ; a>=0 && table[a]==0 ; --a);
+ for(a=value_size-1 ; a>=0 && table[a]==0 ; --a){};

if( a < 0 )
return moving; // all words in table have zero
@@ -635,7 +635,7 @@
*/
bool FindLeadingBit(uint & table_id, uint & index) const
{
- for(table_id=value_size-1 ; table_id!=0 && table[table_id]==0 ; --table_id);
+ for(table_id=value_size-1 ; table_id!=0 && table[table_id]==0 ; --table_id){};

if( table_id==0 && table[table_id]==0 )
{
@@ -667,7 +667,7 @@
*/
bool FindLowestBit(uint & table_id, uint & index) const
{
- for(table_id=0 ; table_id<value_size && table[table_id]==0 ; ++table_id);
+ for(table_id=0 ; table_id<value_size && table[table_id]==0 ; ++table_id){};

if( table_id >= value_size )
{
@@ -878,7 +878,7 @@
// if the value_size is smaller than or equal to 2
// there is no sense to set x1size and x1start to another values

- for(x1size=value_size ; x1size>0 && table[x1size-1]==0 ; --x1size);
+ for(x1size=value_size ; x1size>0 && table[x1size-1]==0 ; --x1size){};

if( x1size == 0 )
{
@@ -886,7 +886,7 @@
return;
}

- for(x1start=0 ; x1start<x1size && table[x1start]==0 ; ++x1start);
+ for(x1start=0 ; x1start<x1size && table[x1start]==0 ; ++x1start){};
}

for(uint x1=x1start ; x1<x1size ; ++x1)
@@ -1100,11 +1100,11 @@
// if the ss_size is smaller than or equal to 2
// there is no sense to set x1size (and others) to another values

- for(x1size=ss_size ; x1size>0 && ss1[x1size-1]==0 ; --x1size);
- for(x2size=ss_size ; x2size>0 && ss2[x2size-1]==0 ; --x2size);
+ for(x1size=ss_size ; x1size>0 && ss1[x1size-1]==0 ; --x1size){};
+ for(x2size=ss_size ; x2size>0 && ss2[x2size-1]==0 ; --x2size){};

- for(x1start=0 ; x1start<x1size && ss1[x1start]==0 ; ++x1start);
- for(x2start=0 ; x2start<x2size && ss2[x2start]==0 ; ++x2start);
+ for(x1start=0 ; x1start<x1size && ss1[x1start]==0 ; ++x1start){};
+ for(x2start=0 ; x2start<x2size && ss2[x2start]==0 ; ++x2start){};
}

Mul2Big3<ss_size>(ss1, ss2, result, x1start, x1size, x2start, x2size);
@@ -1426,8 +1426,8 @@
uint x1size = value_size, x2size = value_size;
uint x1start = 0, x2start = 0;

- for(x1size=value_size ; x1size>0 && table[x1size-1]==0 ; --x1size);
- for(x2size=value_size ; x2size>0 && ss2.table[x2size-1]==0 ; --x2size);
+ for(x1size=value_size ; x1size>0 && table[x1size-1]==0 ; --x1size){};
+ for(x2size=value_size ; x2size>0 && ss2.table[x2size-1]==0 ; --x2size){};

if( x1size==0 || x2size==0 )
{
@@ -1436,8 +1436,8 @@
return;
}

- for(x1start=0 ; x1start<x1size && table[x1start]==0 ; ++x1start);
- for(x2start=0 ; x2start<x2size && ss2.table[x2start]==0 ; ++x2start);
+ for(x1start=0 ; x1start<x1size && table[x1start]==0 ; ++x1start){};
+ for(x2start=0 ; x2start<x2size && ss2.table[x2start]==0 ; ++x2start){};

uint distancex1 = x1size - x1start;
uint distancex2 = x2size - x2start;
@@ -1499,7 +1499,7 @@
uint r = 0;

// we're looking for the last word in ss1
- for(i=value_size-1 ; i>0 && dividend.table[i]==0 ; --i);
+ for(i=value_size-1 ; i>0 && dividend.table[i]==0 ; --i){};

for( ; i>=0 ; --i)
DivTwoWords(r, dividend.table[i], divisor, &table[i], &r);
@@ -1619,12 +1619,12 @@
{
m = n = value_size-1;

- for( ; n!=0 && v.table[n]==0 ; --n);
+ for( ; n!=0 && v.table[n]==0 ; --n){};

if( n==0 && v.table[n]==0 )
return 1;

- for( ; m!=0 && table[m]==0 ; --m);
+ for( ; m!=0 && table[m]==0 ; --m){};

if( m==0 && table[m]==0 )
return 2;
@@ -1635,7 +1635,7 @@
if( m == n )
{
uint i;
- for(i = n ; i!=0 && table[i]==v.table[i] ; --i);
+ for(i = n ; i!=0 && table[i]==v.table[i] ; --i){};

if( table[i] < v.table[i] )
return 3;
@@ -1920,7 +1920,7 @@
// table_id == divisor_table_id as well

uint i;
- for(i = table_id ; i!=0 && table[i]==divisor.table[i] ; --i);
+ for(i = table_id ; i!=0 && table[i]==divisor.table[i] ; --i){};

if( table[i] < divisor.table[i] )
{

Best regards

Ettl Martin

Added by: ~guest, 2010 VIII 31

this patch fixes the Warnings from ttmathbig.h:

Index: ttmathbig.h
============================================================ =======
@@ -4114,7 +4114,7 @@

// we're looking for the index of the last character which is not zero
uint i = uint( new_man.length() ) - 1;
- for( ; i>0 && new_man[i]=='0' ; --i );
+ for( ; i>0 && new_man[i]=='0' ; --i ){};

// if there is another character than zero at the end
// we're finishing
@@ -4468,7 +4468,7 @@
// we could break the parsing somewhere in the middle of the string,
// but the result (value) still can be good
// we should set a correct value of 'source' now
- for( ; Misc::CharToDigit(*source, conv.base) != -1 ; ++source );
+ for( ; Misc::CharToDigit(*source, conv.base) != -1 ; ++source ){};

c += Add(sum);

Added by: tomek, 2010 IX 05

This wargins come from -Wextra flag. For me this is a stupid flag, when you enable it some of the stupid warnings are generated.

Some of them:
ttmathint.h:797:2: warning: base class 'class ttmath::UInt<1u>' should be explicitly initialized in the copy constructor

Why something should be initialized in the copy constructor? I initialize them where I want to.

ttmathuint.h:2412:14: warning: comparison of unsigned expression < 0 is always false

Yes it is, and I use the fact, sample:

for(uint i=0 ; i<value_size-1 ; ++i) { do..something }

if value_size is 1 then nothing is done, if I want to get rid of the warning then I should rewrite it in a following way:

if( value_size > 1 )
for(uint i=0 ; i<value_size-1 ; ++i) { do..something }

This would waste my time and the code would be less clear.

Next, changing:
for( ... );
to
for( ... ){};
is silly too.

I don't want to fulfill stupid wishes from compilers.