public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: Nathan Sidwell <nathan@acm.org>
Cc: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] Fix ODR violations in code using <ext/atomicity.h>
Date: Fri, 21 Jun 2019 17:13:00 -0000	[thread overview]
Message-ID: <20190621171304.GP7627@redhat.com> (raw)
In-Reply-To: <20190621170816.GO7627@redhat.com>

On 21/06/19 18:08 +0100, Jonathan Wakely wrote:
>On 21/06/19 13:01 -0400, Nathan Sidwell wrote:
>>On 6/21/19 12:01 PM, Jonathan Wakely wrote:
>>>Nathan noticed that the 'static inline' functions in <ext/atomicity.h>
>>>cause ODR violations when used from inline functions or templates (see
>>>[basic.def.odr] p12 bullet (12.2)). His modules branch now diagnoses
>>>those violations, so we need a fix.
>>>
>>>Looking at the history (r114044 by Paolo) I believe the idea was indeed
>>>to allow different definitions to be used in different TUs. I think
>>>__attribute__((__always_inline__)) is a better match for that than
>>>'static inline', and doesn't violate the ODR (at least, not if all TUs
>>>have the same values for __GTHREADS and _GLIBCXX_ATOMIC_BUILTINS).
>>>
>>>These functions still violate this rule in [dcl.inline]:
>>>
>>>C++17: "If a function with external linkage is declared inline in one
>>>translation unit, it shall be declared inline in all translation units
>>>in which it appears; no diagnostic is required."
>>>
>>>C++2a WP: "If a function or variable with external or module linkage
>>>is declared inline in one translation unit, there shall be a reachable
>>>inline declaration in all translation units in which it is declared;
>>>no diagnostic is required."
>>>
>>>But that doesn't seem to be diagnosable by today's implementations.
>>>
>>>Does this change seem reasonable?
>>
>>yes, thanks!
>
>Actually, I think I prefer this version. This produces identical code
>to the always_inline version, but without the indirection to
>additional inline functions, i.e. just inline the relevant code into
>the _dispatch functions.
>
>Tests are still running but no failures so far, as expected.

Oops, I spoke too soon:

FAIL: tr1/2_general_utilities/shared_ptr/thread/default_weaktoshared.cc (test for excess errors)
UNRESOLVED: tr1/2_general_utilities/shared_ptr/thread/default_weaktoshared.cc compilation failed to produce executable
FAIL: tr1/2_general_utilities/shared_ptr/thread/mutex_weaktoshared.cc (test for excess errors)
UNRESOLVED: tr1/2_general_utilities/shared_ptr/thread/mutex_weaktoshared.cc compilation failed to produce executable

Those tests explicitly use the __atomic_add function that the patch
removes. But those would be easy to adjust.


  reply	other threads:[~2019-06-21 17:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-21 16:01 Jonathan Wakely
2019-06-21 17:01 ` Nathan Sidwell
2019-06-21 17:08   ` Jonathan Wakely
2019-06-21 17:13     ` Jonathan Wakely [this message]
2019-07-05 16:26       ` Jonathan Wakely
2019-07-05 18:28         ` Daniel Krügler
2019-07-05 19:11           ` Jonathan Wakely
2019-07-06 22:02             ` Jonathan Wakely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190621171304.GP7627@redhat.com \
    --to=jwakely@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    --cc=nathan@acm.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).