On Wednesday 04 December 2024 00:02:11 Martin Storsjö wrote:
> On Tue, 3 Dec 2024, Pali Rohár wrote:
>
> > It is not visible in the diff, but the functions starts with
> >
> > int
> > __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.
Seems that this is truth. So it would be better to remove the {} part.
> > 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
Yes, it is only about duplicated definitions. But for me it sounds
dangerous to use this feature by default.
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public