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: Runtime Link-Loader Behavior and ODR (Is this a Bug?)


On 27 October 2010, Jeffrey Walton wrote:
>
> I've familiarized myself with ISO/IEC 14882 [1] and section 3.5
> Program and Linkage. If a variable (g_Global above) satisfies
> paragraph/clause (9) (ie, names using external linkage in different
> scopes denotes the same object), where is it stated that constructors
> and destructors will run multiple times? I have not found anywhere in
> the standard where an object's constructor and destructors should be
> executed multiple times (cf, Section 12 Special member functions,
> Subsection 1, Constructors).

Apart from the fact shared libraries aren't covered by the standard,
violating the ODR results in undefined behaviour. The standard doesn't
define undefined behaviour, by definition.

Undefined behaviour means anything can happen, the compiler/linker is
not expected to produce sensible results or the results you want,
because you have not conformed to the rules of the language.

> In addition, I don't believe this is a violation of ODR. Section 3.5
> specifies that the named variable is the same object, which brings me
> back to, "Why are constructors and destructors running multiple
> times?".

Do you have a testcase that shows this behaviour?  All your tests I've
looked at do not fit the description above, they have a global defined
in two places, *not* once in libcrypto++.so
The difference is key.  Two definitions violates the ODR. One
definition doesn't (the clue is in the name :-)

Please produce a testcase demonstrating the behaviour you're
describing. I don't care if it uses crypto++, I have that installed
now, if it's too large to post then please send it to me offlist, but
you can't keep claiming a bug without showing evidence.


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