Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The problem is that “allowed to be expected to crash” is one interpretation. Another is “0 initialized” (which debug runtimes sometimes use), another is “whatever was on the stack last time” and another is “we can reorder program and eliminate what you think is logical code”.

    int main() {
      int val;
      if (val == 3) {
        cout << “here” << end;
      }
      return 0;
    }
A perfectly legal interpretation of this program is to remove the call to cout, as is just printing “here” on every run.

> So literally the variable does not have a value at all, as that part of address space is not mapped to physical memory.

There are vanishingly few platforms where the stack you have in a C program maps to physical memory (even if you consider pages from the OS)



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: