This is the mail archive of the 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: IMA corner case with forward declarations of statics

Dale Johannesen <> writes:

>> Are you sure?  6.2.2p4 looks unambiguous that the first declaration
>> does have external linkage, but I remember finding a place that said
>> that a declaration with 'extern' and no initializer had indeterminate
>> linkage, which the subsequent declaration with 'static' retroactively
>> rendered into internal linkage.
> This is correct, you're thinking of 6.9.2.  Your example is valid.

I don't follow your logic.  Here's the first two paragraphs of 6.9.2
(the third is clearly irrelevant and the remainder are examples):

  1 If the declaration of an identifier for an object has file scope
    and an initializer, the declaration is an external definition for
    the identifier.

[not the present situation]

  2 A declaration of an identifier for an object that has file scope
    without an initializer, and without a storage-class specifier or
    with the storage-class specifier static, constitutes a tentative

[... so a declaration with the storage-class specifier 'extern' and no
initializer does _not_ constitute a tentative definition]

    If a translation unit contains one or more tentative definitions
    for an identifier, and the translation unit contains no external
    definition for that identifier, then the behavior is exactly as if
    the translation unit contains a file scope declaration of that
    identifier, with the composite type as of the end of the
    translation unit, with an initializer equal to 0.

[this is what happens if you do have a tentative definition, which we

... so I find nothing here to support the claim that the program is
valid.  I've now gone over to Geoff's opinion that it isn't, and
am proceeding on that theory.


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