Groups | Search | Server Info | Keyboard shortcuts | Login | Register
Groups > gnu.utils.bug > #2266
| From | johnny dude <johnny.dude@gmail.com> |
|---|---|
| Newsgroups | gnu.utils.bug |
| Subject | Re: Bug in the linker |
| Date | 2019-08-21 19:43 +0300 |
| Message-ID | <mailman.606.1566405819.30381.bug-gnu-utils@gnu.org> (permalink) |
| References | <CAKSZggjeNyRv_f+Wc_E4VpnQSZCKsQi8LgxmzMBbDzwJE2vDBA@mail.gmail.com> <mvmpnkyip9e.fsf@linux-m68k.org> <CAKSZggg1Lk01bQ760WhYikm9=a3OBXawwaQYF7+p7aAeddvi8A@mail.gmail.com> |
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 <schwab@linux-m68k.org>
wrote:
> On Aug 21 2019, johnny dude <johnny.dude@gmail.com> 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, schwab@linux-m68k.org
> GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
> "And now for something completely different."
>
Back to gnu.utils.bug | Previous | Next | Find similar
Re: Bug in the linker johnny dude <johnny.dude@gmail.com> - 2019-08-21 19:43 +0300
csiph-web