The project that I'm currently working on is for an large embedded application with a multi-person team. During a recent review of the code I came across the following statement
bSlcIsolated[logical-1] = (!!p_bIsolated);
The interesting part is the double inversion
The register being double inverted, is a private byte within the class. This is just an example, but the developer has used this convention through-out his code, as well as other projects.
With unoptimized code, the compiler generates code which inverts the bit twice. i.e. 01h --> 0FEh --> 01h.
With optimized code, the compiler removes the double inversion.
We can't use the optimizer (managerial decision, because people don't know how to use volatile, a different discussion). This is the first time I've ever seen this and I'm interested in any reasoning why we shouldn't just remove it to eliminate code bloat.
Before you ask I asked the developer, he was very vague, indicating it guaranteed the state, blah blah. But I do know he found it in a code example he downloaded from the web a few years ago, and has used it everywhere since.