-
Notifications
You must be signed in to change notification settings - Fork 101
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
[C++ Verification] fixed cpp if-else typecast #1692
Conversation
Just as a heads-up, this is not the right fix: The rules regarding type promotion in |
Hi @fbrausse , Thanks for your suggestion. Should I handle |
Thanks for the reference. For C++, I think maybe we don't need to do something like "Usual arithmetic conversions". With Clang C++ AST I think we've got enough information. See the results for CI, where we failed one TC for C and fixed several for C++.
For now, I think we can implement adjusting |
However, 6.1) says that, if they have the same type, then something special happens. Only otherwise the usual arith. conv. are being performed.
That would be great, yeah. Maybe you can put the C handling of Edit: In particular item 6.1) is missing for C, so even in |
oh, I see. thanks.
I would like to ask is the implicit typecast provided in the AST not available? I think maybe we can use the information in the AST directly? Isn't that accurate information? |
Do you have a cpp test case where this is failing? I'm surprised that clang doesn't abort before even generating the ast |
Hi @mikhailramalho ,
or
|
Can you double-check it? I'm using esbmc fe3125b and it works just fine:
|
oh, I thought you wanted the code for the AST above, I just gave an example to see that the AST provides type information. Please use this code:
|
I got the crash now, but surprisingly esbmc doesn't crash in release builds, i.e., our backend manages to handle this code just fine... Is the assertion too restrictive? Although I agree that we are missing a cast there. Also, the goto program is weird:
The problem is not accuracy but what later stages of the verification expect. In an ideal world, we would convert the clang AST and everything would work just fine (or better still, we could use clang AST directly), but in reality, it is not that simple. |
I don't think we're missing cast, instead it's doing extra cast. Lines 350 to 353 in fe3125b
I'm a little confused about why the type returned here is
|
Where is the extra cast you mentioned in the goto code? This is the failed assertion:
either we are missing the implicit cast from pointer to array or the assertion is being too restrictive. I vaguely remember we had an |
esbmc/src/clang-c-frontend/clang_c_adjust_expr.cpp Lines 124 to 134 in fe3125b
On line 133, a type cast is performed. turn op1 and op2's |
yeah, but that cast is needed in case of implicit casts
Em ter., 20 de fev. de 2024 às 10:43, Xianzhiyu ***@***.***>
escreveu:
…
https://github.com/esbmc/esbmc/blob/fe3125b4cd4f90a95441fe585b74d429eaa19d99/src/clang-c-frontend/clang_c_adjust_expr.cpp#L124-L134
On line 133, a type cast is performed. turn op1 and op2's array into
pointer.
—
Reply to this email directly, view it on GitHub
<#1692 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAKEJH5L4PNWF2LWUML3LKTYUSSBJAVCNFSM6AAAAABDQ3DXPCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJUGI2DKNRTGA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
--
Mikhail R. Gadelha, Ph.D.
|
I have some questions about this assertion, since we are comparing the type generated by Clang AST as the correct type, why don't we just cast to this type. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@XLiZHI: could you please run this PR over the SV-COMP benchmarks?
Master:
This PR:
I only applied the changes in the C++ frontend, I think this PR has no impact on C verification. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for submitting this PR, @XLiZHI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. We should look into the reasons for the necessity of these additional casts.
No description provided.