This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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: Bug or feature: symbol names of global/extern variables





Wolfgang Roemer wrote on 06/10/2005 16:14:03:

> On Thu Oct 06, 2005 14:50, Robert Dewar wrote:
> >> [..]
> >>
> >>  I actually disagree with this, I think attempting to make the link
fail
> >>  here would be a mistake.
>
> Why do you think that this would be a mistake?
>

I agree with Robert, it would be a mistake. For several reasons:
1. There is code out there that depends on this feature
    (e.g. initialization of std::cin and friends).
    You don't want to break it.
2. I think that it will break C. As I remember, it is sometimes
    legal in C (or in some dialects of C) to have conflicting types.
    You may define in one translation unit:
       char var[5];
    and then go on and define in a different translation unit:
       char var[10];
    The linker will merge both declarations and allocate at least
   10 bytes for 'var' (ld's --warn-common will detect this).
    I don't have C99's spec near me so I can't tell if this is really
    part of C99 or of some dialect of C.

If the linker only warns on mismatched types it gives users a choice.
A user can choose to run the linker with --fatal-warnings (or
gcc -Wl,--fatal-warnings) and get an error. --fatal-warnings
seems to be gnu-ld's equivalent of gcc's -Werror (at least as I
understand ld's man page).

  Michael


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