Skip to content

Comment on Obfuscated Game of Life in 9 lines of Cparent

Comments

Not really. When you declare a variable the system assigns it an address on stack. When you try to read it, it reads the value currently stored at that address. Subsequent reads all read from the same address.

Unless you have something else writing to this address, the value will not change. Since the program's stack is only available to that program, it will stay the same.

Yes, really. I don't think you understand the leeway that C/C++ give implementations when they encounter undefined behavior. Your mental model of how the code "should" be compiled can go out the window when an optimizer designed to work properly only on well-defined code goes to work:

http://blog.llvm.org/2011/05/what-every-c-programmer-should-...

I'm sorry, but nothing in that article contradicts what I wrote. I wrote that once variable is declared, a memory location is assigned to it and this location nor it's content change over time, unless you write to (initialize) it yourself.

Care to quote the sentence(s) that say differently?

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.