Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 9, 2026

Description

ildasm produces platform-dependent NaN comments: Windows outputs // -nan(ind) while Linux outputs // -nan. This causes test failures when comparing IL output across platforms.

Root cause: sprintf_s with %#.17g format produces different strings for NaN values on different platforms.

Changes:

  • Added NormalizeFloatString() in dis.cpp to strip platform-specific suffixes like (ind) from NaN/INF representations
  • Applied normalization after sprintf_s formatting in dasm.cpp for both float32 and float64 literal values
// Before (platform-dependent):
.field public static literal float64 NaN = float64(0xFFF8000000000000) // -nan(ind)  // Windows
.field public static literal float64 NaN = float64(0xFFF8000000000000) // -nan       // Linux

// After (consistent):
.field public static literal float64 NaN = float64(0xFFF8000000000000) // -nan       // All platforms

Customer Impact

Without this fix, tools that compare ildasm output across platforms (e.g., test suites, build verification) see spurious differences in comments. The IL bytecode itself is identical—only comment formatting differs.

Regression

No. This is a long-standing platform difference in ildasm output formatting.

Testing

  • Built CoreCLR successfully on Linux
  • Verified NaN literals now output // -nan without platform-specific suffixes
  • Tested with NaN, +/-Inf for both float32 and float64

Risk

Low. Changes are isolated to comment formatting in ildasm output. The actual IL bytecode and its semantic meaning are unchanged. Only affects the human-readable comments appended to hex representations of special floating-point values.

Original prompt

This section details on the original issue you should resolve

<issue_title>ildasm produces different comments in the output on Windows vs Linux</issue_title>
<issue_description>Run ildasm on the System.Runtime assembly from the Microsoft.NetCore.App.Ref 10.0.0 package on both Windows and Linux and compare the output.

diff --git a/D:/a/_work/1/s/artifacts/bin/Sbrp.Tests/Release/net10.0/GenerateTests-1767801555/normalized-src/targetPacks/ILsrc/microsoft.netcore.app.ref/10.0.0/ref/net10.0/
System.Runtime.il 
b/D:/a/_work/1/s/artifacts/bin/Sbrp.Tests/Release/net10.0/GenerateTests-1767801555/targetPacks/ILsrc/microsoft.netcore.app.ref/10.0.0/ref/net10.0/System.Runtime.il
index e719fceb..afac84a5 100644
--- a/D:/a/_work/1/s/artifacts/bin/Sbrp.Tests/Release/net10.0/GenerateTests-1767801555/normalized-src/targetPacks/ILsrc/microsoft.netcore.app.ref/10.0.0/ref/net10.0/System.
Runtime.il
+++ b/D:/a/_work/1/s/artifacts/bin/Sbrp.Tests/Release/net10.0/GenerateTests-1767801555/targetPacks/ILsrc/microsoft.netcore.app.ref/10.0.0/ref/net10.0/System.Runtime.il
@@ -26609,7 +26609,7 @@
   .field /*04000042*/ public static literal float64 Epsilon = float64(4.9406564584124654e-324)
   .field /*04000043*/ public static literal float64 MaxValue = float64(1.7976931348623157e+308)
   .field /*04000044*/ public static literal float64 MinValue = float64(-1.7976931348623157e+308)
-  .field /*04000045*/ public static literal float64 NaN = float64(0xFFF8000000000000) // -nan
+  .field /*04000045*/ public static literal float64 NaN = float64(0xFFF8000000000000) // -nan(ind)
   .field /*04000046*/ public static literal float64 NegativeInfinity = float64(0xFFF0000000000000) // -inf
   .field /*04000047*/ public static literal float64 NegativeZero = float64(-0.0000000000000000)
   .field /*04000048*/ public static literal float64 Pi = float64(3.1415926535897931) 

Windows produces // -nan(ind) where Linux produces // -nan

While this is non-functional from an il perspective but it causes headaches in my test scenario that is run on multiple platforms.

I am using version 11.0.0-alpha.1.26055.102</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits January 9, 2026 20:03
… consistency

Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
…dback

Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix ildasm output discrepancies between Windows and Linux Normalize NaN output in ildasm for cross-platform consistency Jan 9, 2026
Copilot AI requested a review from agocke January 9, 2026 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

ildasm produces different comments in the output on Windows vs Linux

2 participants