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

On Jun 24, 2004, at 11:11 AM, Zack Weinberg wrote:

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.

OK, I guess you are right. 6.9.2 gives this example:

static int i2=2;
extern int i2;     /*refers to previous, internal linkage */

and nothing about that section suggests that the order of declarations matters.
However, 6.2.2 makes it clear that the order does matter, and the reverse
order is undefined behavior. (Which does not mean we have to treat it as
an error; you and I both thought this was valid, and I'm sure I've seen it
done that way. Disallowing it is sure to break existing code.)

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