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

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

Re: Bug in the linker


From: johnny dude
Subject: Re: Bug in the linker
Date: Wed, 21 Aug 2019 19:43:25 +0300

Thank you for the quick response.

I understand the violation.

In all other cases ld returns an error of: "multiple definitions".
Including the same code, with the constructor defined outside the struct
declaration.

I thought it might be an implementation detail.

On Wed, Aug 21, 2019 at 5:09 PM Andreas Schwab <address@hidden>
wrote:

> On Aug 21 2019, johnny dude <address@hidden> wrote:
>
> > root@44027fc60f45:/# cat a.cpp
> > #include <iostream>
> > struct A { int n; A(int n) : n(n + 10) {} };
> > int a(int n) { return A(n).n; }
> > extern int b(int n);
> > int main(int, char**) { std::clog << a(5) << ", " << b(5) << "\n"; }
> >
> > root@44027fc60f45:/# cat b.cpp
> > #include <iostream>
> > struct A { int n; A(int n) : n(n + 100) {} };
> > int b(int n) { return A(n).n; }
>
> This violates basic.def.odr.
>
> Andreas.
>
> --
> Andreas Schwab, address@hidden
> GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
> "And now for something completely different."
>


reply via email to

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