On Tue, 3 Dec 2024, Pali Rohár wrote:
It is not visible in the diff, but the functions starts withint __mingw_init_ehandler (void) { static int was_here = 0; size_t e = 0; PIMAGE_SECTION_HEADER pSec; PBYTE _ImageBase = _GetPEImageBase (); if (was_here || !_ImageBase) return was_here; was_here = 1; ... which prevents multiple calls. So I think that it should have the same behavior.
Ah, right, that's good.
(And even without the {} added here, IIRC static variables are guaranteed to be zero initialized - they aren't uninitialized like local variables.)Yes, that is truth, this change is not needed. I wanted to make it visible that they are zero initialized. Feel free to drop this part of the change.
I already pushed it, but then Liu Hao pointed out that initializing with = {} without any elements inside of it, is only valid in C23, while older C versions don't strictly allow it (it would have to be { 0 } or something like that). So I'm considering pushing a change to remove that bit.
The behavior is different only for global variables, they are affected by gcc -fcommon/-fno-common options. So for global variables it is a good idea to always initialize them explicitly.
Hmm - even if they're common, they would still be zero initialized, no? Doesn't common/no-common only affect whether duplicates are ok or not?
// Martin _______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
