-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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 compiler warnings silently ignored, giving wrong results/undefined behavior #11590
Labels
Comments
This was referenced Jun 25, 2019
timotheecour
changed the title
c compiler warnings silently ignored, giving undefined behavior
c compiler warnings silently ignored, giving wrong results/undefined behavior
Jun 27, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
After codegen, c compiler warnings are silently ignored; this can give undefined behavior in which I ran into.
Example
Current Output
the output is random stack garbage:
Expected Output
Possible Solution
don't ignore warnings, and even error on warnings (except maybe a whitelist).
When compiling with
--listCmd
we get:if we remove
-w
we get:that warning currently gets ignored without error or any indication of which, and the generated code produces garbage.
The 2nd problem here is that the header is wrong (and also the return type is wrong): it should be:
with this, it gives the expected output.
Note: the reason system/timers actually works is by luck: it's because
MachTimebaseInfoData
itself uses the right header; but minor modifications would re-exhibit that bug, eg if we comment out an unrelated part of the code (egmach_timebase_info(timeBaseInfo)
), that correct header would get optimized out, and the undefined behavior would be there.Note: this bug is obviously not specific to system/timers and can occur in many other unrelated settings
Additional Information
no
The text was updated successfully, but these errors were encountered: