[PATCH][StaticAnalyzer] new check comparing equal expression
Daniel Marjamäki
Daniel.Marjamaki at evidente.se
Thu Sep 26 04:19:30 PDT 2013
Hi Jordan!
> Even though this actually does something ("++x == ++x"), it's not well-defined anyway (specifically, either one could go first), so I'd still like to catch this as a copy-paste error. What do you think?
Yes this is true now as we are only checking comparison operators. However:
1. When we extend it to && and || operators we must be more careful about this. We can of course add logic later that avoids increment only if the top operator is && or ||.
2. I think it would be interesting to add new diagnostics about undefined execution order. Then we will warn about ("++x == ++x") with a stronger warning message that complains about undefined behaviour.
Best regards,
Daniel Marjamäki
..................................................................................................................
Daniel Marjamäki Senior Engineer
Evidente ES East AB Warfvinges väg 34 SE-112 51 Stockholm Sweden
Mobile: +46 (0)709 12 42 62
E-mail: Daniel.Marjamaki at evidente.se
www.evidente.se
More information about the cfe-commits
mailing list