-
Notifications
You must be signed in to change notification settings - Fork 20
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
Imported C code doesn't recognize increment operator and issues false positive warning for endless loop #1081
Comments
Well, the problem is indeed that Structorizer does not support auto-increment and auto-decrement operators as executable syntax. So the Analyser component won't recognize a working modification of variable fH[y++] = 0.0 into
isn't that trivial in the general case, particularly not in case of several occurrences of auto-increment/-decrement or combined operators +=, -= etc. for the same variable within a single complex expression. Consider e.g. the expression On the longer sight, of course, an effort might be considered to
|
Just a related remark: |
I've read and understood your points. I do understand, having been there done that, how complicated it can be to mimmick a programming language to make any kind of assertion on the code, specially for a language with the historic baggage and the ensuing incoherences in syntax, asymmetries in API, etc. Tools like Structorizer (and for NSD even other implementations) have to put a stop in some place and I get that for the present state of Structorizer those compound statements was the decision taken. I'll address this question of Kay's, which I hope wasn't as a rethoric one[!]:
I think the most sensible and correct way would be to take the code generated by a [conformant] compiler! Perhaps using libclang to get an "intermediate level" structure and elude having to parse assembly code. The ROI in such effort is, of course, theme for another debate to which I've no stance a priori. One interesting point in the NSD above is that translating this:
into
Would take out the "atomicity" of the operator and create the illusion that in the NS diagram the So the first part of the decision on keeping these operators as they are seems to me appropriate whereas the recognizing of their semantic in the code seems the most appropriate route in a future enhancement, which, I think, parallels the second bullet in the options above. PS.: Some of these "rearrangements" in code are already done in Structorizer, for example Footnotes
|
@csrabak
This might indicate a way for certain language families were such an intermediate level exists (libclang might be fine for C, C++, C# etc. but then we would have to use a quite different package for languages like Pascal, Java and, well, you name it). So the more specific our tool would be dedicated to certain language familiy the easier and more complacent it might get. On the other hand, the more general its application is intended the less satisfying the result will be for certain kinds of language. Anyway we require the imported code to adhere to structured algorithmic constructs (e.g. there won't be any efforts to try to make sense of spaghetti jumps).
Why is this an illusion? In this algorithm the incrementation of |
In both sides of the comparison the var
y
is postincremented, so the supposed condition is not there.The text was updated successfully, but these errors were encountered: