Boost logo

Boost Testing :

From: Stephen W. Carson (StephenC_at_[hidden])
Date: 2005-06-07 08:59:48

Beman Dawes wrote:

> Thanks! In the meantime, I've gotten email from Metrowerks identifying
> the
> exact bug in their code. I checked in a better fix an hour ago; let's
> hope
> that will do the job.

    I'm not sure if I picked up your change last night but the test
failure hasn't gone away. I started my tests between 10 and 11pm CST.

    I'll be running one more time tonight before going on vacation. I'll
run non-incremental so I make sure to pick up changes.

> PS: Here is the original Metrowerks code:
> if (info.st_mode & S_IFDIR == S_IFDIR) // Wrong!
> Howard Hinnant spotted the obvious, which had eluded their C library
> folks:
> if ((info.st_mode & S_IFDIR) == S_IFDIR) // Correct

    What a nightmare operator precedence is! (This sort of error can
also be avoided if you have the warning turned on in your compiler that
warns you if your conditional evaluates to a non-boolean type. As you
can see with this subtle bug in MW code, this is a warning worth turning

    Here's what is BELOW the precedence of equal(==) and not equal (!=) and
therefore needs to be guarded by parens in a conditional:
bitwise AND (&), exclusive OR (^), inclusive OR (|)
logical AND (&&), logical inclusive OR (||)
simple assignment (=)
* and assign (*=, /=, %=, +=, -=, etc.)
conditional expression (expr ? expr : expr)
throw exception
comma (expr, expr)

Stephen W. Carson, Software Engineer
DirXion Software in St. Louis, MO
(636) 717-2367
The Boost Wiki:

Boost-testing list run by mbergal at