I guess upgrading compiler isn't an option then

Unfortunately in your real code, this could be due to undefined behaviour interacting with compiler optimisation, rather than a compiler bug. But if it is due to a compiler bug involved writing a zero to previously zeroed memory, then that suggests a workaround: don't zero the memory. Now, if it must have static storage duration then that's not an option, but otherwise it might work. If you really need the trailing unused portion of the array to be zeroed, you could always do a memset after fgets instead.