This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: gnu.linkonce too aggressive
On Thu, Mar 09, 2000 at 09:15:18AM +0100, Martin v. Loewis wrote:
> > Shouldn't the file name from where the function was taken be included
> > in the section name instead of "gnu.linkonce" ?
>
> Thanks for your bug report. This is not a bug in the compiler; it is a
> bug in your code: there are no static classes in C++. Instead, you are
> declaring qq and ww as static variables.
I knew that; I used static to demonstrate that the global constructors
get the unique name, as opposed to the class constructor.
> As a result, you have two definitions for A::A(), thus violating the
> one definition rule. As such violation does not require a diagnostic
> by the compiler, your program has undefined behaviour.
Well, the compiler cannot diagnose it at all, it will be left to
collect2 or the linker, but can the compiler provide the information
that could be used to diagnose the violation, if collect2 happens to
be courteous enough?
> Instead of static classes, you should use unnamed namespaces.
This helps, thanks.
Leo