3F / DllExport

.NET DllExport with .NET Core support (aka 3F/DllExport aka DllExport.bat)
MIT License
938 stars 131 forks source link

error : syntax error at token '-' in: IL_002d: ldc.r8 -nan(ind) with "return Double.NaN" #158

Closed tapika closed 4 years ago

tapika commented 4 years ago

Steps to reproduce:

Create demo project with function, which returns

return Double.NaN;
    C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC>where ildasm
    C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\ildasm.exe

     C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC>ildasm /?|more
     Microsoft (R) .NET Framework IL Disassembler.  Version 4.0.30319.17929

Same code does not work with Visual Studio 2019.

    C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise>where ildasm
    C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\ildasm.exe

    C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise>ildasm /? |more
    Microsoft (R) .NET Framework IL Disassembler.  Version 4.8.3928.0

I have tried to override this by modifying project settings and enforcing specific tool version, like this:

    <DllExportILAsmCustomPath>C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7.2 Tools</DllExportILAsmCustomPath>

After that project compiled in both Visual studios.

Suspect some ildasm bug, at least looks somehow similar to: https://github.com/3F/DllExport/issues/128#issuecomment-565651841 =>

https://developercommunity.visualstudio.com/content/problem/545431/ildasmexe-regression-with-infinum-floating-point-v.html

Is this the same problem perhaps ?

I have vs2019 16.6.0, but there is update available, need to try it on.

3F commented 4 years ago

Confirmed.

NaN for single and double precision is now processed as -nan(ind) instead of (00 00 C0 FF) and (00 00 00 00 00 00 F8 FF), respectively.

Temporary solution: as it was already noticed, please use either our IL Assembler or custom path to any official version less than 4.8

3F commented 4 years ago

Optional NaNToken patching has been planned for 1.7.3

.field = float32(-nan(ind)) -> 0xFFC00000
.field = float64(-nan(ind)) -> 0xFFF8000000000000

ldc.r8 -nan(ind) -> 00 00 00 00 00 00 F8 FF
ldc.r4 -nan(ind) -> 00 00 C0 FF

You can check this via related CI build 9f26c9ba2dfa3be47c62653855e0b89f5d57637e