Mail Archives: djgpp/1999/09/27/07:32:12
The solution is to _use_ the value of i, otherwise it's optimised out
of the loop.
Martin Str|mberg (ams AT ludd DOT luth DOT se) wrote:
: Hmm. It's strange, when I really want to make my program crash with
: SIGSEGV it seems impossible to achive that.
: Here's my test prorgam:
: #include <limits.h>
: #include <stdio.h>
: int
: a_very_long_function_name_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(void)
: {
: unsigned long *i_p;
: unsigned long i;
: for(i_p = NULL; i_p < ULONG_MAX-1000000; i_p += 409600)
: {
: printf("i_p = 0x%lx.\n", i_p);
: i = *i_p;
/* Here we use i! Nice SIGSEGV, here it comes. */
printf("i = 0x%ld.\n", i);
: }
: }
: int main(void)
: {
: a_very_long_function_name_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx();
: return(0);
: }
Right,
MartinS
- Raw text -