Is there any
good reason for not having the ability to turn off overflow checks in
VB.NET Express I know that this is an "advanced" option, but lots of common code code doing some binary operations will break and not be usable for beginners to run and study.
That's pretty bad IMHO. There's the workaround of course by putting the
"RemoveIntegerChecks" XML element in the vsproj file manually, but why
all this pain, Microsoft, why Thanks for listening!

How to turn off Overflow Checks?!?
capere
Vaughn
Interesting.
When writing for rocketry, I hope they aren't using VB! You are right, of course, the there are a few assembly lines of code attached to the overflow checking - but it's not something a VB programmer, I believe, should worry about.
It comes down to philosopy, really: VB for me, is a program to get things done. Programming is not a job, it's a tool. It doesn't have to be efficient, it has to be effective. I don't want it kicking me when I least expect it. Such things that we are discussing here is one of those things - we've all heard of the dreaded buffer overflow issues - it's a similar problem.
Indeed, the nature of a lot of my programming often repeats bounds checks on arrays, for example, if the code is called bupassing the initial bounds check, there's an additional one to catch it - true, the end result may be unexpected, but at least it will be observable and rectified relatively quickly. Stability over efficiency is paramount - and really should be for any high level language programmer.
(Now, if I'm more interested in efficiency, say, for a flux vector drive, calculating the virtual field value on a three phase motor, then clock cycles on an 8mhz processor matters. This is going to be C code with a smattering of hand optimized assembler.)
Do programmers need to be aware of such things Of course. But it's all about appropriate tools: C programming is ideal to teach and learn about basic data structures, bit representation, overflows, algorithms, etc. If you actually want to get something done (i.e. a usable product) then a higher level, more productive, environment is needed. (obviously, it depends on the market - there is a negligible market elegant and efficient C code, though).
Johan Van Antenaeken
Go ahead and purchase the more advanced IDE: Standard or professional if you really need this feature.
VBExpress is a tool designed for beginners, who may not even know what an integer overflow check is, so presenting all these options wil overwealm the beginner. VB Express is (currently) free with a cut down featureset. Turning off such compiler options is not a beginners feature.
szary
kankudai
Grayson Peddie
The VB compiler will be happier if you tell it that the constant that you are assigning to n is an unsigned long (using the UL suffix).
Const n As UInt64 = &H8000000000000000UL
Dim a As UInt64
a = n
If I wanted to "allow" overflows, I'd probably be explicit about what I wanted to happen in my code by using the next larger type in my calculation and mask off the bits that I was interested in.
Dim offset As UShort
Dim data As Integer() = New Integer(63999) {}
offset = 30000
data(offset) = 1
offset = CUShort((42000 + offset) And UShort.MaxValue)
data(offset) = 2
Of course, to do this would have been more difficult if I wanted to use a UInt64 in the first place...
Best regards,
Johan Stenberg
Snow Ko
int x = 0xffffffff;
is not legal, but you have to write it like this:
int x = __unchecked((int)0xffffffff);
Overflow checks are good, don't get me wrong. Yet be aware that code performance suffers a little bit, too.
OwenGraupman
If you're teaching, it's difficult for me to see the virtue of code that has overflows to begin with.
DaveNieberding
I'm very thankful that:
Dim offset as UShort
offset = 30000
causes and overflow.
However
const n As Uint64 = &H8000000000000000
Dim a As Uint64
a = n
Will also cause an overflow and I don't think that's correct.
Tobias M
Dim data as Integer() = New Integer(63999) {}
offset = 30000
data(offset) = 1
offset += 42000
data(ofs) = 2
Happy overflowing!
franz
What kind of code wouldn't run I can't imagine any kind of beginner appropriate code which wouldn't run under such circumtances.
Even so, if you supplied such code to a user - which you say wouldn't run because of the integer checks - even with the professional edition you would have to inform your users to disable it. If this is just an example for the students, editing the XML is not a big deal, anyway.