warning on assignment within conditional

Ian Lance Taylor iant@google.com
Thu Feb 11 04:33:00 GMT 2010


"John (Eljay) Love-Jensen" <eljay@adobe.com> writes:

>> We're using iwmmxt_le-g++ (GCC) 3.3.1 (MontaVista 3.3.1-7.0.2.0401382 2004-10-07) ...
>
> Ahh, C++.
>
>> But it doesn't produce a warning on this line
>>        if (bFoundFile = false) {
>> which is the actual code line that prompted my question.
>
> In C++, a bool is a truth value.  If bFoundFile is a bool, then that constitutes a truth value.  So it would not result in a warning.


I actually fixed that not too long ago, and current versions of g++ do
give a warning for this construct.  gcc 3.3.1 is quite old, though.  I
think the warning is new in 4.4, or possibly 4.3.

Ian



More information about the Gcc-help mailing list