On 18/09/15 18:45, Martin Sebor wrote:
but it makes me wonder how common this pattern is in portable code and whether adding workarounds for it is the right solution (or if it might prompt people to disable the warning, which would be a shame).
Perhaps if we are going to warn, we could look for sizeof() and virtual locations in the operands, and skip the warning. It would be nice to find a heuristic that allows warning in most cases but skip those that appear often in common code.
Another alternative is to have a more heuristic version of operand_equal(), if two operands are equal because of "compilation-dependent" code (macro expansion, sizeof, etc), then they are not considered equal. that is operand_equal_2(sizeof(long), sizeof(long)) returns true, but operand_equal_2(8, sizeof(long)) returns false.
I have no idea whether it is possible to implement operand_equal_2 in a sane way. Cheers, Manuel.