Sparecode could eliminate unnecessary if statements
ID0000927: This issue was created automatically from Mantis Issue 927. Further discussion may take place here.
Id | Project | Category | View | Due Date | Updated |
---|---|---|---|---|---|
ID0000927 | Frama-C | Plug-in > sparecode | public | 2011-08-17 | 2014-02-12 |
Reporter | djs52 | Assigned To | Anne | Resolution | fixed |
Priority | normal | Severity | minor | Reproducibility | always |
Platform | - | OS | - | OS Version | - |
Product Version | Frama-C Carbon-20110201 | Target Version | - | Fixed in Version | Frama-C Nitrogen-20111001 |
Description :
This arose trying to use the [sparecode] plugin from another plugin, where constant propagation has reduced a conditional to "if (1)". However, a similar case from the command line is:
int main (int x) { //@assert x>5; if (x > 5) { return 3; } else { return 4; } }
frama-c -sparecode-analysis /tmp/test.c
... /* Generated by Frama-C / int main(int x ) { int __retres ; /@ assert (x > 5); */ ; if (x > 5) { __retres = 3; } return (__retres); }
Note that although [sparecode] has figured out that the else branch can be ignored, it has not removed the if condition, which is also redundant by the same reasoning.