-
Notifications
You must be signed in to change notification settings - Fork 12.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
Inconsistent const_err
on index access to array in polymorphic functions
#65005
Comments
I think this is related to #64419 which made the I believe this behavior is covered under RFC 1129 so this is expected behavior. |
From the quoted RFC, emphasis mine:
That RFC only seems to argue for not erroring. It remarks that this is a breaking change and one that would not be forseeable by the user since the compiler may get arbitrary additional powers of evaluating constant expression and goes on to specify that it should only warn if the context is not a true
Treating the warning as |
It is our normal policy that warnings may be turned into deny-by-default lints. The specific lint has been deny-by-default for a long time. What we cannot do is turn these into hard errors. That is, I think @wesleywiser is correct that this is expected behavior and I'm closing the issue accordingly. |
@Centril Okay, so this was a misunderstanding on the exact wording, and you cleared up what the RFC was meant to express. However, this never showed up as a warning in the first place. Indeed, stable is silent even if turning this into an explicit warning. There was no way to diagnose that this would be an issue before the error in nightly right now. Under this aspect it does not behave like a warning having been turned into a deny-by-default lint. |
It sometimes happens, such as in this case, that we extend existing lints to more cases. To avoid that we would need to split |
@Centril True, it would add uncertain complexity. To aid cost/benefit analysis, we're talking about But more generally, doesn't continuing this train of though mean that any other crate which wants to stay long-term compatible with At the end of the day, this can be solve like a library bug–publishing a new version. Those with necessarily old compilers stay unaffect, those with newer ones available can update. It's fine, thanks for consideration and time. |
To me this seems like a loophole in |
@sinkuu Just to clarify, the macro in question is declared in the |
@HeroicKatora Oh, the failing macro is used only in |
@sinkuu I wasn't aware of that and of course only tested by downloading and then adding a path replacement.. That's very calming to know 😄 |
Stable currently allows indexing an array with invalid constant indices in polymorphic functions without warnings. A recently nightly change has apparently changed this behaviour into an error. The following builds on stable without warnings but errors on nightly:
It should be noted that in monomorphic functions this is already an error in both version, though I do not know when this was introduced. That is, this is an error:
It is also an error (in both versions) if the actual access is statically unreachable:
Note: This breaks
image
and everything that depends on it, many versions.The
image
crate makes use of the index access in a macro where the alpha components of a pixel are accessed (see here). It properly guards this with a check on the component number but, statically speaking, the access exists in the CFG even for types without alpha components where the index is of course invalid. This seems like a regression that would usually have an incompatibility warning period.The text was updated successfully, but these errors were encountered: