-
Notifications
You must be signed in to change notification settings - Fork 289
Unit tests are constant-folded #86
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
Comments
I suspect we can inhibit this with liberal usage of |
In #88 looks like @BurntSushi do you think we should use |
Probably yeah :-/ |
If they are constant folded, doesn't that mean they are correct? |
Under certain assumptions, yes. We generally trust that the compiler's constant-folding rules are correct. However, they are actually not guaranteed to be correct under all circumstances. On test case failed because of constant folding. Floating point instructions actually can have side effects on certain processor-specific status registers (MXCSR on x86 / Another problem I can think of might be that an emitted instruction could actually fail at runtime under certain circumstances (e.g., CPU feature not supported / invalid instruction on certain platforms). You cannot rely on the compiler's constant folding code to take those specific details into account. Platform-specific intrinsics are generally not on the highly-tested code paths of the compiler, so we want to make sure that our test cases actually test something more than just the constant-folding parts of the compiler. |
I'll be ok by working around compiler bugs by using
We should arguably tests both cases because our users won't probably be using |
I'm going to close this because I think these aren't constant folded in debug mode so we should be getting some good testing there, and otherwise the constant folding probably means that the intrinsic is correct! |
I noticed that some of our unit tests get constant folded which probably defeats their purpose. For example, when compiled with
cargo +nightly test --release
the testcompiles to:
That looks like a no-op to me, so I suspect that this test is constant-folded by the compiler.
The text was updated successfully, but these errors were encountered: