https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43565
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |hubicka at gcc dot gnu.org,
| |matz at gcc dot gnu.org
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Simplified testcase, optimized with -fno-common, not optimized without.
Likewise
if g and f are 'extern' this is not optimized independently of -fno-common.
That is, the issue is whether &g or &f might resolve to NULL if in another unit
they are declared weak.
void link_error();
int g, f;
int main()
{
if (&g == &f)
link_error ();
return 0;
}
so the issue is probably fear of
> cat t.c
extern void abort ();
extern int g, f;
int main()
{
if (&g == &f)
abort ();
return 0;
}
> cat t2.c
int f __attribute__((weak)), g __attribute__((weak));
being miscompiled somehow. While the above ends up with WEAK symbols,
the objects still get allocated. If I make f and g extern in t2.c
I still get unresolved references at link time.
So sth is not exactly set up.