https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85678
Bug ID: 85678 Summary: -fno-common should be default Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: david at westcontrol dot com Target Milestone: --- The use of a "common" section to match up tentative object definitions in different translation units in a program is contrary to the C standards (section 6.9p5 in C99 and C11, section 6.7 in C90), gives a high risk of error, may lead to poorer quality code, and provides no benefits except backwards compatibility with ancient code. Unix C compilers have traditionally allowed "int x;" in file a.c to be allocated by the linker to the same storage as "int x;" in file b.c when these two C files are linked together. gcc supports this if "-fcommon" is enabled, which is the default on most targets. But it is contrary to the C (and C++) standards that say there shall be exactly /one/ definition of each object. And it is very easy to have errors in code by accidentally having duplicate names in different files (if the programmer has not used "static"), perhaps even of different types. With "-fno-common", such errors are caught at link time. Also, data in common sections will hinder some types of optimisation, such as "-fsection-anchors". Surely it is time to make "-fno-common" the default, at least when a modern C standard is specified indicating that the code is modern? People who need the old behaviour can always get it with "-fcommon".