This is the mail archive of the
mailing list for the GCC project.
Re: IMA corner case with forward declarations of statics
On Jun 24, 2004, at 11:11 AM, Zack Weinberg wrote:
Dale Johannesen <email@example.com> 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
However, 6.2.2 makes it clear that the order does matter, and the
order is undefined behavior. (Which does not mean we have to treat it
an error; you and I both thought this was valid, and I'm sure I've seen
done that way. Disallowing it is sure to break existing code.)