Thread overview
Strange behaviour
Jun 07, 2007
Simen Haugen
Jun 07, 2007
Thomas Kuehne
Jun 07, 2007
Manfred Nowak
Jun 07, 2007
Simen Haugen
Jun 07, 2007
Regan Heath
Jun 08, 2007
Simen Haugen
June 07, 2007
I just encountered a strange bug that I'm having problems reproducing as a test case.

I used an associative array to store some data lengths, and in my code, I was accessing an element not in the array. In debug mode, this code did not fire ArrayBoundsError and worked (returning 0 I guess), but in release mode it crashed. Any ideas why this might have happend?


June 07, 2007
Simen Haugen schrieb am 2007-06-07:
> I just encountered a strange bug that I'm having problems reproducing as a test case.
>
> I used an associative array to store some data lengths, and in my code, I was accessing an element not in the array. In debug mode, this code did not fire ArrayBoundsError and worked (returning 0 I guess), but in release mode it crashed. Any ideas why this might have happend?

Did you check that "invariant", "unittest" and "in/out" of in/out/body have no side effects appart from debugging output?

"aa[non_existant]" should allways throw an exception however "non_existant in aa" simply returns null.

Thomas


June 07, 2007
Thomas Kuehne wrote

> Did you check that

same for asserts.

-manfred
June 07, 2007
"Thomas Kuehne" <thomas-dloop@kuehne.cn> wrote in message news:slrnf6gb6a.coh.thomas-
> Did you check that "invariant", "unittest" and "in/out" of in/out/body have no side effects appart from debugging output?

Yes.

> "aa[non_existant]" should allways throw an exception however "non_existant in aa" simply returns null.

Yes. The problem is that the exception wasnt raised in the debug build.


June 07, 2007
Simen Haugen Wrote:
> I just encountered a strange bug that I'm having problems reproducing as a test case.
> 
> I used an associative array to store some data lengths, and in my code, I was accessing an element not in the array. In debug mode, this code did not fire ArrayBoundsError and worked (returning 0 I guess), but in release mode it crashed. Any ideas why this might have happend?

Was the key to the AA a char[] and do you .dup the key when you store values?  If not, is it possible that you have modified the char[] you used for the key, this can have some unexpected results and behaviour.

That's all I can think of.

Regan Heath
June 08, 2007
No, its an int[int] array

"Regan Heath" <regan@netmail.co.nz> wrote in message news:f4a2jm$7u2$1@digitalmars.com...
> Simen Haugen Wrote:
>> I just encountered a strange bug that I'm having problems reproducing as
>> a
>> test case.
>>
>> I used an associative array to store some data lengths, and in my code, I
>> was accessing an element not in the array. In debug mode, this code did
>> not
>> fire ArrayBoundsError and worked (returning 0 I guess), but in release
>> mode
>> it crashed. Any ideas why this might have happend?
>
> Was the key to the AA a char[] and do you .dup the key when you store values?  If not, is it possible that you have modified the char[] you used for the key, this can have some unexpected results and behaviour.
>
> That's all I can think of.
>
> Regan Heath