[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#570838: missing warning, false error



I think there are inconsistencies warnings.

#include <iostream>
int main( void ) {
  for ( int i=0, j=99 ; (++j) = 99 , i<9 ; ++i ) {
    std::cout << i << ' ' << j << std::endl;
  }
  return 0;
}

/usr/bin/g++ -Wall the source code above yields NO warning, while the increased value 100 of j is UNUSED, since the assigment will overwrite with 99 again.


In addition to the missing warning above, we have a false error below:


Swapping the timing of the ++ opertor, namely using the expression

	(j++) = 99

yields the ERROR below:

	In function 'int main()':
	3: error: lvalue required as left operand of assignment

Hence (++j) is a left value, while (j++) is not.  This is inconsistent.

Each of the expressions ++j, j++ and j has the same left value as the others. It is an independent and different question how the value at the location in question is affected by the presence and the position of the operator ++. But the both of ++j and j++ have a left value identical to the left value of j, not?


I have cheked, that omitting the parenthesis does not help.

Regards,
	Peter PROHLE.



Reply to: