Hacker News new | ask | show | jobs
by gvb 3820 days ago
It does if your target system properly zeros bss because, by the rules, array[10] will be placed in bss and bss is zeroed. If you replace the initializer with {1}, you force the compiler to file to a different rule that forces the compiler to explicitly initialize everything to 1.

The problem I've had (and you probably are referring to) is embedded systems that may not properly zero bss. I've also had problems in embedded systems trying to place "array[10] = {0};" into a specific non-bss section (that was really annoying).

In my experience, TFA is good practices generally, but will have problems in corner cases that you run into in deeply embedded systems.

1 comments

This is incorrect, `int array[10] = {1}` initializes all but the first element with 0.