D - array bounds checking question.
- chris jones (6/6) Sep 10 2002 I have read that it is posible to turn it off but is this globaly or can...
- Burton Radons (10/14) Sep 10 2002 In those situations you'll want to use the two-register loop as well, so...
- Sandor Hojtsy (10/24) Sep 11 2002 you
- chris jones (9/37) Sep 11 2002 can
- Pavel Minayev (2/5) Sep 11 2002 Array bounds checking is on in debug builds by default.
- chris jones (11/16) Sep 11 2002 be a
- Sean L. Palmer (9/23) Sep 11 2002 This is making me want language support for iterators.
I have read that it is posible to turn it off but is this globaly or can you do it for specific blocks of code as you can in Delphi? I like to leave it on for the most part and just turn it off in specific places where a significant speed benefit is to be had. thanks, chris
Sep 10 2002
chris jones wrote:I have read that it is posible to turn it off but is this globaly or can you do it for specific blocks of code as you can in Delphi? I like to leave it on for the most part and just turn it off in specific places where a significant speed benefit is to be had.In those situations you'll want to use the two-register loop as well, so the method kills two birds: int [] x = new int [45]; for (int *c = x, end = c + x.length; c < end; c ++) ... Voila, no bounds checking. If you want to index without the bounds check, you can cast: ((int *) x) [l] There's no way to turn it off for a block of code.
Sep 10 2002
"Burton Radons" <loth users.sourceforge.net> wrote in message news:3D7E80A3.9010608 users.sourceforge.net...chris jones wrote:youI have read that it is posible to turn it off but is this globaly or canitdo it for specific blocks of code as you can in Delphi? I like to leaveHmm. Seems quite an automatic task. Maybe the optimizing compiler could generate similar code if you don't tinker with the array length inside a simple loop. A single bound check before the loop would do.on for the most part and just turn it off in specific places where a significant speed benefit is to be had.In those situations you'll want to use the two-register loop as well, so the method kills two birds: int [] x = new int [45]; for (int *c = x, end = c + x.length; c < end; c ++) ...Voila, no bounds checking. If you want to index without the bounds check, you can cast: ((int *) x) [l]What if we invent a new property: int a = x.unchecked(1);There's no way to turn it off for a block of code.That's OK.
Sep 11 2002
"Sandor Hojtsy" <hojtsy index.hu> wrote in message news:almqrr$1tv7$1 digitaldaemon.com..."Burton Radons" <loth users.sourceforge.net> wrote in message news:3D7E80A3.9010608 users.sourceforge.net...canchris jones wrote:I have read that it is posible to turn it off but is this globaly oryouleavedo it for specific blocks of code as you can in Delphi? I like toitI like the idea, mabey 'unsafe' would be a better keyword, it dicourages use for people who mabey dont know whaht they are doing. Plus there should be a global switch to force bounds checking to aid debuging so you dont have to alter the source code. chrisHmm. Seems quite an automatic task. Maybe the optimizing compiler could generate similar code if you don't tinker with the array length inside a simple loop. A single bound check before the loop would do.on for the most part and just turn it off in specific places where a significant speed benefit is to be had.In those situations you'll want to use the two-register loop as well, so the method kills two birds: int [] x = new int [45]; for (int *c = x, end = c + x.length; c < end; c ++) ...Voila, no bounds checking. If you want to index without the bounds check, you can cast: ((int *) x) [l]What if we invent a new property: int a = x.unchecked(1);
Sep 11 2002
chris jones wrote:for people who mabey dont know whaht they are doing. Plus there should be a global switch to force bounds checking to aid debuging so you dont have to alter the source code.Array bounds checking is on in debug builds by default.
Sep 11 2002
"Pavel Minayev" <evilone omen.ru> wrote in message news:alo40g$1abb$1 digitaldaemon.com...chris jones wrote:be afor people who mabey dont know whaht they are doing. Plus there shouldtoglobal switch to force bounds checking to aid debuging so you dont haveYes but i mean if it did become posible to have an option to turn bounds checking of for certain pieces of code, it would also be desirable to be able to force them to bounds check in debug builds. As it is its all or nothing. I still want bound checking in release builds but with the option of turning it off for certain bits of code, but still be able to overide that globaly for debug builds. chrisalter the source code.Array bounds checking is on in debug builds by default.
Sep 11 2002
This is making me want language support for iterators. Pointers are just a wee bit more dangerous of a thing than you need in this case. And the two register loop is commonplace enough it deserves representation or at least syntax sugar. Sean "Burton Radons" <loth users.sourceforge.net> wrote in message news:3D7E80A3.9010608 users.sourceforge.net...chris jones wrote:youI have read that it is posible to turn it off but is this globaly or canitdo it for specific blocks of code as you can in Delphi? I like to leaveon for the most part and just turn it off in specific places where a significant speed benefit is to be had.In those situations you'll want to use the two-register loop as well, so the method kills two birds: int [] x = new int [45]; for (int *c = x, end = c + x.length; c < end; c ++) ... Voila, no bounds checking. If you want to index without the bounds check, you can cast: ((int *) x) [l] There's no way to turn it off for a block of code.
Sep 11 2002