bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ld bug!


From: BluesLan
Subject: ld bug!
Date: Tue, 8 Oct 2002 15:15:14 +0800

Dear Sirs,
 
Sorry to bother you with this confusing phenomenon. I'm not sure whether it's a ld bug or not. Read the following descriptions please:
 
I've 2 simple and unmeaningful C source files(just for describing my problem), and they contribute to a simple project :
 
<t1.c> :
char qq=11;
void test2(void);
int main()
{
    printf("sizeof(qq)=%d\n", sizeof(qq));
    test2();
    return 0;
}
 
<t2.c>
char *qq;
void test2(void)
{
    qq=88;
    printf("sizeof(qq)=%d\n", sizeof(qq));
}
 
==============================
As above shown, these 2 source files both define a variable qq, it should cause the bug of multiply-defined symbols while linking, but it won't! The compiling and linking processes work successfully! The most confusing result is that I get 2 different size of the same variable(I guess ld treats the 2 qqs as the same variable) while executing:one is length 1, the another is length 4!
If I initialize the variable qq in t2.c(e.g., char *qq=0;), the ld reports "multiply definition of 'qq'". It's the result I wish, but I wonder why ld cannot report this bug if I do not initialize qq in t2.c.
 
the version of gcc : 2.96 20000731
the version of ld : 2.11.90.0.8
the environment : RedHat 7.2
 
Thanks for you response!
 
Best Regards,
Blues

reply via email to

[Prev in Thread] Current Thread [Next in Thread]