JustinStitt wrote: @efriedma-quic > Note that I'd be open to just deciding to ignore the C standard requirement > here because it's unhelpful, but we need to at least document it.
Here's the full paragraph from [the standard C6.2.4p6](https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2310.pdf) ``` For such an object that does not have a variable length array type, its lifetime extends from entry into the block with which it is associated until execution of that block ends in any way. (Entering an enclosed block or calling a function suspends, but does not end, execution of the current block.) If the block is entered recursively, a new instance of the object is created each time. The initial value of the object is indeterminate. If an initialization is specified for the object, it is performed each time the declaration or compound literal is reached in the execution of the block; otherwise, the value becomes indeterminate each time the declaration is reached. ``` My interpretation of this last sentence > If an initialization is specified for the object, it is performed each time the declaration or compound literal is reached in the execution of the block seems to line up with the current state of this PR. e.g., `g()` returns 0 ```c int g() { int b = 0; BEGIN:; int c; if (b) return c; // returns 0 else { c = 5; b = 1; goto BEGIN; } } ``` I'll document this behavior but I don't think we are actively disregarding the standard, I suppose it is up to the interpretation of "initialization is specified for the object" and whether or not `-ftrivial-auto-var-init=zero` is something that specifies initialization for objects in the same way the sentence refers to. https://github.com/llvm/llvm-project/pull/181937 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
