Now I'm curious, is it correct (not UB) to uses values in `buffer` from a previous iteration? If so, using `-ftrivial-auto-var-init=` is actually breaking programs that do so.
Bug 1808891 Comment 4 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
Now I'm curious, is it correct (not UB) to use values in `buffer` from a previous iteration? If so, using `-ftrivial-auto-var-init=` is actually breaking programs that do so.
What is the expected output of this program?
```c
#include <stdio.h>
int main() {
int max = 0;
for(int i = 0; i < 10; i++) {
int buffer[10];
if(i == 0) {
buffer[0] = 0;
}
else {
buffer[i] = buffer[i-1] + 1;
}
if (buffer[i] > max) {
max = buffer[i];
}
}
printf("%d\n", max);
return 0;
}
```
https://godbolt.org/z/rfGdbPzos
https://godbolt.org/z/3h4ncTx69 (with -ftrivial-auto-var-init=zero)