Path: csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail From: johnny dude Newsgroups: gnu.utils.bug Subject: Re: Bug in the linker Date: Wed, 21 Aug 2019 19:43:25 +0300 Lines: 36 Approved: bug-gnu-utils@gnu.org Message-ID: References: NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: usenet.stanford.edu 1566405820 27664 209.51.188.17 (21 Aug 2019 16:43:40 GMT) X-Complaints-To: action@cs.stanford.edu Cc: bug-gnu-utils@gnu.org To: Andreas Schwab Envelope-to: bug-gnu-utils@gnu.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=3orYumaPMqLhwPMfW2vYT0jKSLcAbbDoRFBx7+2yeb0=; b=So/+SAtSV8Iish7mkIeTsogn0D8+zVUJr4tTAjkoYYKpX0Xlk5jSx0UPJf1D4slw3d lVRJ3ViJ+PIFL1xDBFs7FGYNLIj8IcWdjdqIrWZgDVAwg5UVUz4BNS0n/Bz2MHNtSHxw CxRVi0apfmfdUfKbFtwL6oyS1m8kJVieYxnkQ8XxsdBQUcdvRkKzDzys5mNMuQEBTzmi hGdA+79V6lmALjA6bJRwOcsYVFPHlzjv+0R0pbeZfSQAejx9ZzEBJi0RTjlDLCTQiiaS oYY+PSLmGPIwxQekhHElS2n5lWuv6iLEFX0l3Ju27sMc28yvkdFOu8CSaeeaajZvHs8M DQfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=3orYumaPMqLhwPMfW2vYT0jKSLcAbbDoRFBx7+2yeb0=; b=gn5M4q0hALkHFxZ5EeqMiyEUsZdPCUlCiHEgQFxPZs7mpV6o1r7Sig480/QtRVmHyM HJdjzAnJ6p55TX1NVmjSlGJmzmjjlTCXzIA5MGz/+A/W/WvkWT6VgInOIhSUlToHKs24 JirLId+r+X/YucJ3nGCJCQDxxpqhbvMo5ArVopnKpJA87gQLO1+BHtNdfg/YdQEJuEs9 3z6DEThNNKTVuEfapauFFiWWgNZBCmfBf6GVv4/ClzwTXApfZd1EGwJvblL65eGeeANw UYmS5D08zvGoctytemgcAZ5VuzDgcWp0iw2R7Ybtcz7wItdNpmu5QXX4EwBTf24zd+SH hRLw== X-Gm-Message-State: APjAAAW9SZFMOpjoymlfEkVMpnfF+fNnE3ZOL4KAwlMoVmk5B6YS4IYq OGoHrcGJv5QbdDxaTCbYr5DasbNkxDV2UoQWWFai3w== X-Google-Smtp-Source: APXvYqzhjr6DRgaEbPPDDX39ikm4pfDpqYeAKX93eZtTV99FfMCPpVYcFfQMIIwPmCevQKpiTDxNQFozWJfr5Fpxd+E= X-Received: by 2002:ac2:5194:: with SMTP id u20mr19157454lfi.40.1566405813787; Wed, 21 Aug 2019 09:43:33 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::12a X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: bug-gnu-utils@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Bug reports for the GNU utilities List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: Xref: csiph.com gnu.utils.bug:2266 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 wrote: > On Aug 21 2019, johnny dude wrote: > > > root@44027fc60f45:/# cat a.cpp > > #include > > 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 > > 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." >