You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Literal overflow warnings should only apply to decimal. #24361
E.g. 0x8888i16 should not warn. Similar to binary operations | and &, hexadecimal, binary, and octal literals are often used to specify the concrete representation in memory whereas decimal literals are used to represent abstract values.
Also note that -(0x8000i16) which evaluates to -32768 (hex: 0x8000i16, which is the minimum value of i16) currently does not warn.
@rust-lang/lang should we close this given the resolution of #48073? There's no suggestion to write 0x8888u16 as i16, but #48432 could be expanded to do so. Otherwise, if we're not suggesting that, then we we should close this in my opinion.
I'm going to go ahead and close this as I think we've essentially intentionally chosen a path here and I believe the suggestion has been implemented, if indirectly, by showing what the literal in i16 would be. It seems like largely writing the "end result" or allowing the lint is an acceptable tradeoff.
Activity
steveklabnik commentedon Jun 27, 2016
Triage: @rust-lang/lang , what do you think about this? This does still warn today, and I'm not sure where i stand, personally.
eddyb commentedon Jun 27, 2016
I would say that
0x8888u16 as i16is the "correct" form, but I'm a bit torn.pnkfelix commentedon Jul 4, 2016
I agree with @eddyb
Also, regarding the
-(0x8000i16)that does not warn: that falls at runtime on builds with overflow checking. E.g. debug builds.estebank commentedon Aug 15, 2018
@rust-lang/lang should we close this given the resolution of #48073? There's no suggestion to write
0x8888u16 as i16, but #48432 could be expanded to do so. Otherwise, if we're not suggesting that, then we we should close this in my opinion.Mark-Simulacrum commentedon Sep 8, 2019
I'm going to go ahead and close this as I think we've essentially intentionally chosen a path here and I believe the suggestion has been implemented, if indirectly, by showing what the literal in i16 would be. It seems like largely writing the "end result" or allowing the lint is an acceptable tradeoff.