Skip to content

Remove tests for warnings for test of UB that are NOT correct with LLVM. #3038

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

Closed
wants to merge 3 commits into from

Conversation

shawnl
Copy link
Contributor

@shawnl shawnl commented Aug 10, 2019

See #2 at the end:

http://blog.llvm.org/2011/05/what-every-c-programmer-should-know_21.html

These generally just return undefined value, but sometimes that undefined
value is just certain bits, and Zig isn't prepared to do such analysis.

The tests on / and % are correct however, because undefined can be 0,
and division or remainder on 0 can cause a SIGFPE (as can INT_MAX / or % -1)

There are more sophisticated cases where the result IS defined,
but not warning on those is much more difficult, this does not actually remove
even the easier to remove bogus warnings.

There is a special case here that is also important, in that undef ^ undef => undef,
NOT 0.

shawnl added 3 commits August 10, 2019 10:59
See ziglang#2 at the end:

http://blog.llvm.org/2011/05/what-every-c-programmer-should-know_21.html

These generally just return undefined value, but sometimes that undefined
value is just certain bits, and Zig isn't prepared to do such analysis.

The tests on / and % are correct however, because undefined can be 0,
and division or remainder on 0 can cause a SIGFPE (as can INT_MAX / or % -1)

There are more sophisticated cases where the result IS defined,
but not warning on those is much more difficult, this does not actually remove
even the easier to remove bogus warnings.

There is a special case here that is also important, in that undef ^ undef => undef,
NOT 0.
@andrewrk andrewrk added this to the 0.5.0 milestone Aug 19, 2019
@andrewrk
Copy link
Member

This looks like an attempt to solve #1947 but it doesn't actually change the behavior, just the tests. More useful than this PR would be adding a comment to #1947 noting all the differences (so that we have a checklist). The implementation of #1947 will remove these tests and add additional tests which exercise the undefined values at comptime and runtime and make sure behavior is correct.

That issue is probably not very contributor friendly - if you tackle it I recommend one operation at a time, at least for the first few PRs.

@andrewrk andrewrk closed this Sep 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants