This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: -fzero-initialized-in-bss again


kenner@vlsi1.ultra.nyu.edu (Richard Kenner) writes:

>     Let me rephrase: if the only purpose of this line is to mimic what the
>     C compiler does with common variables and the Ada compiler doesn't
>     need common variables, let's delete the line.
> 
>     So the question that would be good to answer is: does the Ada compiler
>     need common variables?
> 
> I have non clue what a "common variable" might mean.

A common variable has semantics which more or less follow the way
FORTRAN common statements are handled.  Specifically, multiple common
definitions of a variable are permitted.  There may be exactly zero or
one non-common definition of a variable.  When there are multiple
common definitions and no non-common definition, the size of the
variable is the size of the largest common definition.

Very old C compilers used these semantics for uninitialized
definitions in C.  So, for example, a program which had "char a[10];"
in one file and "char a[100];" in another file, with no initialized
"char a[NN];" anywhere, would link without error, and "a" would wind
up as a 100 byte array.

Current C compilers use these semantics only for backward
compatibility.  Standard C doesn't actually permit doing this,
although the standard describes it as a common extension.

> What we are discussing is what object file section each variable
> should go into.  And what I'm saying is that this shouldn't depend on
> whether a variable was written in C or Ada: it should only be a function
> of language-independent attributes.

"Common" is not an object file section in the usual sense.  The
"common" section is an imaginary section, along the lines of the
"undefined" section (which holds all references to otherwise undefined
symbols).  The common section has no size or address.  Putting a
symbol in the "common" section implies that the symbol should have the
semantics defined above.

If Ada does not have variables which have semantics like those
described above, then Ada should never use the common section.
Regardless of whether -fcommon was specific.  -fcommon is, in my
opinion, really a C specific option.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]