This is the mail archive of the gcc-help@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: Global variable in static library - double free or corruption error


> that there can only ever be one definition of a symbol in a program, and
> UNIX has always merged multiple definitions to achieve this
Does the rule include that gloabl object destructors are to run on
every unload, or the last/final unload or last call to dlclose (when
the shared object gets unmapped)? Many folks don't expect their
objects will be pulled out from under them until the last unload. It
seems like a reasonable expectation to me.

>  it's just something to get used to
Agreed.

On Thu, Oct 21, 2010 at 12:10 PM, Andrew Haley <aph@redhat.com> wrote:
> On 10/21/2010 04:34 PM, Alexey Skidanov wrote:
>
>> Thanks for your response. You are absolutely right regarding to
>> -Wglobal-variable. I would prefer to get some kind of error (linking
>> error?) about two global variables with the same name instead of dynamic
>> loader/linker decision to "merge" them.
>
> This is standard, and correct behaviour. ?The One Definition Rule says
> that there can only ever be one definition of a symbol in a program, and
> UNIX has always merged multiple definitions to achieve this. ?Also, plenty
> of programs depend on this behaviour: it's just something to get used to.
>
> Andrew.
>


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