3 ms·
No, it is undefined behaviour. Check the spec.
by chrisseaton 7y ago
No, it is undefined behaviour. Check the spec.
- saagarjha 7y agoI couldn't find the verbiage for that. The standard seems to have this under undefined behavior: > The value of an object with automatic storage duration is used while it is indeterminate. But reading the value without using it seems fine?
- chrisseaton 7y agoThe 'object' in this context is the storage location, not the value you read from it. You're 'using' the 'object' when you read from it.
- deleted 7y ago[deleted]
- saagarjha 7y agoOh, not that kind of read. I meant "read" in the context of "without actually using its value in a way that affects your program execution"–not, in what I believe the C++ term is–an ODR use. As in here: https://news.ycombinator.com/item?id=22740582 https://news.ycombinator.com/item?id=22740582