Yes, it's now only for testing. Later on i will only have case insensitive version. But thanks for other tips...
Printable View
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)...
Thanks matsp ;)
EDIT: How can I assure that I get SIGSEGV or anything on such invalid access?
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