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
Supplemental fix for issue 13783 in std.parallelism #2773
Conversation
`auto f(ref ubyte);` should not take an lvalue of `enum E : ubyte`. Fixing 13783 will disallow the accepts-invalid bug.
Ready to merge. This PR is necessary for the compiler fix: dlang/dmd#4177 |
What makes this change necessary? Would similar user code also break as a result of the dmd PR? |
Reduced code to show the bug in current std.parallelism module. enum E : ubyte
{
a, // 0
b, // 1
c // 2
}
void invalidSet(ref ubyte stuff)
{
stuff = 10;
}
void main()
{
E e = E.a
invalidSet(e); // oops
// e will be modified to a value out of the range of E without any casts.
// it's a hole in type system.
} The |
I see. But now we're making them template functions just to work around this problem? Wouldn't that introduce template bloat? |
To reduce template bloat, we could replace those private functions with the direct calls of core.atomic functions. But, it would introduce casts everywhere. The std.parallelism author doesn't like that. (See the code comment from line 197). |
Autotester failure on Win32, not sure if it's related to this PR or just another one of those heisenfailures. |
It's definitely unrelated. |
OK. |
Auto-merge toggled on |
Supplemental fix for issue 13783 in std.parallelism
Thanks! |
auto f(ref ubyte);
should not take an lvalue ofenum E : ubyte
.Fixing 13783 will disallow the accepts-invalid bug.