Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unchecked integer conversions #84

Open
AnthonyDGreen opened this issue May 27, 2017 · 4 comments
Open

Unchecked integer conversions #84

AnthonyDGreen opened this issue May 27, 2017 · 4 comments
Labels

Comments

@AnthonyDGreen
Copy link
Contributor

No description provided.

@KlausLoeffelmann
Copy link
Member

What is the difference between this and #82?
If it is about unchecked/checked, aren't the compiler options sufficient to control this?
(Maybe I have not understood the background enough.)

@xieguigang
Copy link

Hi, @KlausLoeffelmann unchecked/checked compiler options just working on the constant like enum in the compiling time, but not working on the vb runtime, if a integer variable its actual value is larger than its greatest value, then this still caused the vb program crashed at runtime.

One of the example is the hash algorithm that using the unchecked overflows, and actually this can not working in vb directly yet, but can be simulated using BigInteger. Example like blizzard hash using unchecked int64 in vb using BigInteger to simulate the unchecked, but it is still not so convenient and did not working properly.

@KlausLoeffelmann
Copy link
Member

Although I never tried this, I had this in mind. Are we talking about the same? If we do, do we need to update the description of that document?

https://docs.microsoft.com/en-us/dotnet/visual-basic/reference/command-line-compiler/removeintchecks

@xieguigang
Copy link

Probably doing something like C# unchecked in vb:

Dim i% = Integer.MaxValue

UnChecked
    i += 10
End UnChecked

Console.WriteLine(i)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants