neo-devpack-dotnet icon indicating copy to clipboard operation
neo-devpack-dotnet copied to clipboard

`checked` does not handle the `-x` operation.

Open nan01ab opened this issue 1 year ago • 1 comments

In inc operation, Neo-VM script and standard C# program will throw an Exception both if src overflowed:

public static int Inc(int src)
{
     return checked(++src);
}

In -x operation, standard C# program will throw an Exception if src overflowed(src is -2147483648), but Neo-VM script not:

public static int Negative(int src)
{
     return checked(-src);
}

nan01ab avatar Sep 20 '24 14:09 nan01ab

This apparently a compiler bug, please fix it.

Jim8y avatar Sep 20 '24 15:09 Jim8y

Better to merge https://github.com/neo-project/neo-devpack-dotnet/pull/1205 first

Hecate2 avatar Nov 21 '24 03:11 Hecate2

https://github.com/neo-project/neo-devpack-dotnet/pull/1205 was closed. Maybe it's time to handle many potential problems in simulating overflow.

Hecate2 avatar Dec 12 '24 08:12 Hecate2

"/" => (OpCode.DIV, false), int.MinValue / (-1) ?

Hecate2 avatar Dec 12 '24 08:12 Hecate2

"/" => (OpCode.DIV, false), int.MinValue / (-1) ?

Yes, this also needs to be checked.

nan01ab avatar Dec 12 '24 12:12 nan01ab