From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by server2.sourceware.org (Postfix) with ESMTPS id 64AFB385E830 for ; Sat, 7 Mar 2020 19:27:48 +0000 (GMT) Received: by mail-wr1-x42d.google.com with SMTP id n7so6210352wrt.11 for ; Sat, 07 Mar 2020 11:27:48 -0800 (PST) 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=ESHjdc6SQ3/3YvIp63Y32wLwxr+iKSslt5AuQTAn1TY=; b=N/vwbH5Sik7BW8/FbAmcAkK7k5+hB5lHA8vMbCwaffi+4j5z1NdNAQpROcRs6mvTXn rVjj0Gsm5IwQR2L99B2WUTs4e6PIgF87T/wOYpowxs7AKOfflN/ocfasGwPnx2CFumxg /HGdrazLbYfJ9dGdGKoPUY36AUSBkZriW3CMsc1AXM0GvitsqQOKqwKZE84KUR2i6Z9p uAGmT9Ilu919N58ezTROgx1AFodIj644zWs/ronatcUnB1SDRaehj5TEJtsPgEw3koGb UUpO9ISQapQizkTdq9yOOW/MryyMqOvkgRAmRNzumE3apEzq3oZllHw701LcevNTsDiS onIQ== 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=ESHjdc6SQ3/3YvIp63Y32wLwxr+iKSslt5AuQTAn1TY=; b=OK9OQcFZNWAo+5VI6ksaezZIvKg3H+b+QGF6C7EHjfEvlnRM1yl8BMEEv2a3e5WJmJ wmrjxw4EADlfK0VDl9rv1UZ8EsisUa1tKAbCKbL7ktD6F5W2iScSvSPCDGhfjQnN3ZMl k1iUF/xASEYFnrdtctBm2YPZ6J4BtT/jcdmvVHNhDQR1vITjue7vS+mKJiwLbuOcbPtm r3pvd044m5Jm2CILbGbRPtUD0Si0u1suzg2o7oYu2cr+Ypy1QkmJ/otacyLlSb51j7z8 b53ZqC2TaYt5qTeOCxGIJz2Mx7D1eMq377uBI1cWRTLiB49VywksxMkRUjdLB9VXqpYY fn/w== X-Gm-Message-State: ANhLgQ3DBA7rc98A1T/duUd5kNqorLUMg9EY6vUXwMLwjUUbVYktbb18 et3sERVeCGi5cfk70kRRDelqgXZi4+JiZZeVhxc= X-Google-Smtp-Source: ADFU+vv34SU6V2GsOo9NHKJ92UZusSXF/ruIWanukzyKWcDjEx23Cj5QLZsXGQtzjBU7zWrWgf8AYnqygp3aq8g0Mu0= X-Received: by 2002:a05:6000:1246:: with SMTP id j6mr10679756wrx.253.1583609267131; Sat, 07 Mar 2020 11:27:47 -0800 (PST) MIME-Version: 1.0 References: <72f6344e-d8b2-bab4-b047-63e298063492@gmch.uk> <76f5d98b-affc-111b-5493-2557f8facaf1@gmch.uk> <02d60fa2-0671-31c3-3d4a-1749eb0a6c7b@gmch.uk> <0da8efac-dd6a-f250-97fa-ee322b994961@redhat.com> In-Reply-To: <0da8efac-dd6a-f250-97fa-ee322b994961@redhat.com> From: Jonathan Wakely Date: Sat, 7 Mar 2020 19:27:35 +0000 Message-ID: Subject: Re: Should atomic_xxx() functions reject not-_Atomic() arguments ? To: Andrew Haley Cc: Chris Hall , gcc-help Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Mar 2020 19:27:49 -0000 On Sat, 7 Mar 2020 at 11:00, Andrew Haley wrote: > > On 3/6/20 5:45 PM, Jonathan Wakely wrote: > > On Fri, 6 Mar 2020 at 16:17, Chris Hall wrote: > > > >> FWIW: clang gets this right, and where the Standard says a parameter > >> must be an _Atomic(foo_t)* [for a standard atomic_xxx()], clang rejects > >> foo_t* arguments. > > > > It's not clear to me that C actually requires it to be rejected, or if > > it's just undefined (in which case GCC's decision to accept it and do > > the obvious thing is OK). > > Except in pedantic mode. If the standard doesn't actually forbid it (which I don't think it does) then it's up to the implementation if and when it diagnoses it. Doing so for -pedantic might be reasonable though. > I remember there was a move to actually permit > this in C++: > > http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4013.html > > This seems obviously right to me... Yeah. The feature is in C++20, via the std::atomic_ref template. You wrap an ordinary non-atomic variable in an atomic_ref and can perform atomic operations on it. For this to work, the implementation has to be able to accept non-atomic variables in its __atomic_xxx functions (though not necessarily in the public atomic_xxx ones).