Skip to content
Discussion options

You must be logged in to vote

The behavior you're observing is a C# specific semantic around constant folding which the spec leaves as implementation-defined and which Roslyn has "succeeding" instead of blocking it: https://github.com/dotnet/csharpstandard/blob/draft-v8/standard/expressions.md#12123-division-operator

If the left operand is the smallest representable int or long value and the right operand is –1, an overflow occurs. In a checked context, this causes a System.ArithmeticException (or a subclass thereof) to be thrown. In an unchecked context, it is implementation-defined as to whether a System.ArithmeticException (or a subclass thereof) is thrown or the overflow goes unreported with the resulting value b…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@andanteyk
Comment options

Answer selected by andanteyk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants