Skip to content

unary negation of enum constant always yield 0

ID0002090: This issue was created automatically from Mantis Issue 2090. Further discussion may take place here.


Id Project Category View Due Date Updated
ID0002090 Frama-C Kernel public 2015-03-19 2016-01-26
Reporter virgile Assigned To yakobowski Resolution fixed
Priority normal Severity minor Reproducibility always
Platform - OS - OS Version -
Product Version Frama-C GIT, precise the release id Target Version - Fixed in Version Frama-C Magnesium

Description :

The following code (note that g is only here to retain the enum definition itself in the generated AST).

enum Foo { E1, E2, E3 };

int f() { return !E1; }

int g() { return E1; }

is translated by Frama-C as

enum Foo { E1 = 0, E2 = 1, E3 = 2 }; int f(void) { int __retres; __retres = 0; return __retres; }

int g(void) { int __retres; __retres = E1; return __retres; }

f should in fact return 1, as E1 is bound to 0

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information