-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
sync: need a way to guarantee that WaitGroup.state1 fields are always 4-bytes aligned #27577
Comments
I don't mind adding a compiler hint but I would prefer it to be one that the compiler might actually recognize. I think it's unlikely that the compiler will ever recognize your suggestion. Note that it's more or less OK for the standard library to assume behavior that is not guaranteed, because if the behavior changes, the standard library can change at the same time. This is not true for packages outside the standard library. |
|
I understand the facts. I just want to make it perfect in theory. :) |
Can't this be solved simply by adding a test that will make all.bash fail if the field doesn't have the expected alignment? |
@CAFxX A |
Closed, for WaitGroup aligns fields by using atomic.Uint64 / |
I have noticed and am glad that the suggestion mentioned in #19149 is adopted. But I feel the current new implementation is still not perfect.
The current implementation assumes that the
WaitGroup.state1
field is always 4-bytes aligned, but I can't find any such guarantee is written down in any official Go documentation.So I suggest that we should add a method like the following for
*WaitGroup
. The method will never be called, it just gives compilers a hint that theWaitGroup.state1
field needs to be 4-bytes aligned.The text was updated successfully, but these errors were encountered: