Which GCC 10 default change causes link failures for tentative globals?
26.8K reputation · 10 Nov 2023, 07:26 UTC
Background
Local builds compiled with GCC 9 link successfully even when the same uninitialized global variable appears in multiple translation units. In production, after upgrading to GCC 10+, the same source fails with “multiple definition” errors.
Root Cause
GCC 10 changed the default handling of tentative definitions from -fcommon to -fno-common. The linker now rejects multiple tentative definitions that previously merged into a single common block.
Uncertainty
It is unclear whether the codebase intentionally relies on the old common‑block behavior or whether the failures expose hidden initialization bugs that the new default would otherwise reveal.
Questions
Which GCC flag should be added to restore the legacy behavior? Does using -fcommon mask subtle bugs that the new default would expose? What build‑time checks can detect tentative global conflicts before a compiler upgrade?