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: IMA corner case with forward declarations of statics



On 23/06/2004, at 7:43 PM, Zack Weinberg wrote:


Consider the following test case:

A.c:
    int foo = 12;
B.c:
    extern int printf(const char *, ...);
    extern int foo;

    int main(void)
    {
        printf("%d\n", foo);
        return 0;
    }

static int foo = 14;

Taken together, this is a correct C program which should print 14.

Actually, this is a violation of 6.2.2 paragraph 7,


If, within a translation unit, the same identifier appears with both internal and external linkage, the behavior is undefined.

We should probably print a proper error message.



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