-
Notifications
You must be signed in to change notification settings - Fork 274
__CPROVER_assume behaviour different --float-overflow-check in CBMC 5.48 and CBMC 6.4 #8633
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Confirming that there is something weird going on, consider this modified version of your example (and now using the latest CBMC release): union IntFloat {
float f;
unsigned int i;
};
int main(void) {
union IntFloat a;
__CPROVER_assume((a.i == 0x3f800000u) || (a.i == 0));
unsigned ai = a.i;
float af = a.f;
__CPROVER_assert(!__CPROVER_isinff(a.f), "");
} which yields the following trace:
Note that |
Turns out this is a bug in union field sensitivity when using uninitialised variables (which is undefined behavior in C anyway, but we've obviously tolerated this for a long time). You can avoid this problem by doing: union IntFloat __VERIFIER_nondet_(void);
int main(void) {
union IntFloat a = __VERIFIER_nondet_();
union IntFloat b = __VERIFIER_nondet_();
float c;
__CPROVER_assume((a.i == 0x3f800000) || (a.i == 0));
__CPROVER_assume(b.i == 0);
c = a.f + b.f;
} which will then successfully verify using all known versions of CBMC. |
Ah, that makes sense. I chose a slightly roundabout workaround, and this is a better solution. Thanks! In general, would |
No, this problem is very specific to unions as for those we (also) have one symbol for each member, yet still need to keep the values in sync across them. |
Apologies for not testing on 6.6 but I'm running Ubuntu 20.04.
For this file, I get verification successful (no overflow, correct) on 5.48 and verification failure on 6.3.1 and 6.4 :
Here's the trace from 6.4:
and the trace from 5.48
The text was updated successfully, but these errors were encountered: