www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Strange behaviour

reply "Simen Haugen" <simen norstat.no> writes:
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? 
Jun 07 2007
next sibling parent reply Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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 -----BEGIN PGP SIGNATURE----- iQIVAwUBRmgsx7ZlboUnBhRKAQIPww//QAX3Z/NPiJH9JiwlCxjWGZoliqpyUx2k /dC7r1vUPqugXS3FzLF9DD+haYr/o2PNFqoBYWqYG6Jw4zmFl3LlIwWUOaNcI3kR KZjCdJHS7f1T8e2YwQOHJXrADIklGwlwo0W0X+OxixpDAUHilcPbz6Eyo4uo2gkB QOt0k8uW1LZ2O6VHPhfCV1CzZJ4PsEkFH0Jb8ovgzjP/zAsw6zkAihvElgox7g7d AHyvjpy82u+eB3ej+H7lH0Dv6Ix+dQNOecOlW/L5sk9d4zB4HYkJU0JfniJMt4hV vZxXuOPfsaN7c2M5xi+O2Qac9Q6xpj6WLfwMQGfmI64nJT+MDtUBr0XwPMzBbS/G H4iIUeSkskWQRexa8wkOg+yeb/cwiBTB6cP4ooBwE8thnRU5PCnXh8gs6cCQu5lX vRSdaydejwXJcZcfVG7fh0dchpzNGhnZvZXcXTJ6EfXam2863nMbkT9rRO5EmPJo VMsWhgvkL7GsCmld4J97UkhoZssS9bHuz2+6jJYIvuhwVaIgoxmz3OVDgcc9XLD7 FhmN5C290H6l+qAF4wYFlWVQePtsFk2CS1HONN3sfr2eJN6AUKP8Oea/N7dZESCG NjNyz2X1N668MFnV3f8FBFBKEekLNxkIdrsn5q/vf7IhdsA/Iz0NkgTES7Q2lbHm 7FjFnxCCp/Q= =4nER -----END PGP SIGNATURE-----
Jun 07 2007
next sibling parent Manfred Nowak <svv1999 hotmail.com> writes:
Thomas Kuehne wrote

 Did you check that
same for asserts. -manfred
Jun 07 2007
prev sibling parent "Simen Haugen" <simen norstat.no> writes:
"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.
Jun 07 2007
prev sibling parent reply Regan Heath <regan netmail.co.nz> writes:
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
Jun 07 2007
parent "Simen Haugen" <simen norstat.no> writes:
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
Jun 08 2007