3 ms·
Technically (at least on x86 and ARM), if b() allocates memory on the stack and returns a pointer to a(), as long as the pointer is dereferned immediately after
by colejohnson66 11y ago
Technically (at least on x86 and ARM), if b() allocates memory on the stack and returns a pointer to a(), as long as the pointer is dereferned immediately after the call the b(), the value should still be the same. It's not something you should count on (and purposely relying on it is a sin), but it won't kill your program.
http://ideone.com/oIZXTY http://ideone.com/oIZXTY
- shultays 11y agoIt is an undefined behavior. It is very likely that something will go wrong, especially when optimizations are on. It is something you should never really on.