-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Undefined behaviour in slice::fill
specialization.
#87891
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
I think the fix should be as simple as using |
The other option is just removing the |
It does help the gcc codgen backend at least as it can't manage to produce a memset for u64 so I assume it would fail to do the same for u8 if it weren't for that specialization. |
@the8472: It also fails for the |
It does call memset if you don't pass an array. https://rust.godbolt.org/z/x4KT99heT |
I'd think the |
Reopening to track adding a test. (That's the standard procedure for this, isn't it?) |
@RalfJung I would like to try working on adding the test, though this will be my first contribution so I'd need some guidance. I'm assuming this would be a miri test as it's related to correctness--may I DM you on Zulip? (or would someone else be more suitable?) |
@atsuzaki great. :) Miri runs the libcore test suite via https://github.com/rust-lang/miri-test-libstd. So adding it as a test in libcore makes most sense, IMO. |
This was reported by @the8472 on Zulip: https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/potential.20UB.20in.20slice.3A.3Afill/near/248871405
Demo:
The text was updated successfully, but these errors were encountered: