Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

For you

Name: Anonymous 2012-01-12 14:20

What is the output of this program and why?

#include <stdio.h>

void f(void) {
  printf("hax my anus\n");
  fflush(stdout);
  f();
}

int main(void) {
  f();
  return 0;
}

Name: Anonymous 2012-01-12 15:00

No. The standard assumes that the host environment has sufficient resources to store and execute the program code itself -- which means that things like stack overflows and static allocation failures cannot happen on the C abstract machine. The behavior of the program is thus well defined, it prints "hax my anus\n" ad infinitum.

You might argue that these assumptions aren't sound, but it would be absolutely silly in any other case. What if the environment has insufficient resources to load the program code, should we be able to catch and deal with a code allocation failure?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List