dotnet / dotnet/csharpstandard

12.20 Any caveats around constant evaluation?

Open
#121 7 comments 0 reactions 0 assignees View on GitHub
type: clarity
Dominant language
C#
Stars
815
Forks
99
Avg merge
1d 14h
Merged PRs (30d)
16

Description

> The compile-time evaluation of constant expressions uses the same rules as run-time evaluation of non-constant expressions, except that where run-time evaluation would have thrown an exception, compile-time evaluation causes a compile-time error to occur.

I know this wasn't the case pre-Roslyn for `decimal`, as the implementation of `decimal` arithmetic had very slightly different rules to the CLR. (I can dig up the connect issue if necessary.)

I'm wondering whether there are other things we need to be aware of, such as the use of 80-bit arithmetic, different types of signalling NaN etc (probably not the latter, given the lack of expression evaluation). Worth asking wiser heads.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.