| ▲ | anilakar 2 hours ago | |
It would have resulted in an uninitialized variable access warning, though. | ||
| ▲ | uecker 2 hours ago | parent | next [-] | |
I don't think so. The value is set in the assignment in the if statement even for the success path. With and without defer you nowadays get only a warning due to the misleading indentation: https://godbolt.org/z/3G4jzrTTr (updated) | ||
| ▲ | mort96 2 hours ago | parent | prev [-] | |
No it wouldn't. 'err' is declared and initialized at the start of the function. Even if it wasn't initialized at the start, it would've been initialized by some earlier fallible function call which is also written as 'if ((err = something()) != 0)' | ||