EDIT1: deleted.
Yes i get those messages, and they show indexing is wrong, right?
EDIT2:
But what about if c1 is negative, it gets indexed in table OK, but as TABLE[] is initialized with POSITIVE integers - c1 gets converted to positive and that test fails because of that?
EDIT3:
Solved. It gives 0 from "outter space", so it never crashes (as I expected)...
Last edited by rasta_freak; 08-06-2008 at 06:08 AM.
Thanks matsp
EDIT: How can I assure that I get SIGSEGV or anything on such invalid access?
Last edited by rasta_freak; 08-06-2008 at 05:58 AM.
Realistically, you can't. The reason being that you can not control where in memory your TABLE ends up, so you can't guarantee that what is before or after it is invalid memory. That is what you have assert and similar functionality for - checking for things that should not matter.
By the way, if you compile with optimization enabled, I suspect there will be no big difference in the form that casts your char to unsigned char for the table access.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.