This is not really OpenBSD related but since it's a UNIX-like OS and
here are really experienced people coding in C I thought this was a good
place to ask.

   Coding some simple stuff in C I ended up having a harmless mistake (I
hope) a double-declared variable with different types (char and int for
the example) in wich I did assignements beyond the bounds of the type
size. Let's call it foo, declared in files compiled separatedly. Also
say that everything it's compiled with gcc -c option (exect the final
executable) without warnings of any kind:

   file a.c  contains "char foo" on the code.
   and b.c  contains "int foo" on the code.

   on the b.c file I made an assignement bigger than de byte limit,
let's say 0x2211 for the example. Back to a.c later than the 0x2211
assignement I printed the variable and showed 0x11 (at that point i
realized the mistake). But I was just wondering where the h*ll went the
0x22 bits on the memory?? I mean, the code reserved 1 byte as foo was
declared as a char, and I assined there more than expected (0x2211 for
example).

   I know the rigth thing is to declare the variable 'foo' on a header
file and include it in all my code but I was just curious, what happends
to the upper 0x22 ?? Was I accessing to a ilegal zone of memory?? the
code executed without any error :o and the compiler showed no warning.

Thanks for your time, and sorry for my english.
-J

Reply via email to