{"id":2226647,"url":"http://patchwork.ozlabs.org/api/covers/2226647/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/cover/bmm.hhunfc5mlg.gcc.gcc-TEST.peppe.36.1.0@forge-stage.sourceware.org/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/projects/17/?format=json","name":"GNU Compiler Collection","link_name":"gcc","list_id":"gcc-patches.gcc.gnu.org","list_email":"gcc-patches@gcc.gnu.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<bmm.hhunfc5mlg.gcc.gcc-TEST.peppe.36.1.0@forge-stage.sourceware.org>","list_archive_url":null,"date":"2026-04-22T17:47:27","name":"[v1,0/1] WIP: libstdc++: constrain std::atomic's default constructor","submitter":{"id":93222,"url":"http://patchwork.ozlabs.org/api/people/93222/?format=json","name":"peppe via Sourceware Forge","email":"forge-bot+peppe@forge-stage.sourceware.org"},"mbox":"http://patchwork.ozlabs.org/project/gcc/cover/bmm.hhunfc5mlg.gcc.gcc-TEST.peppe.36.1.0@forge-stage.sourceware.org/mbox/","series":[{"id":501056,"url":"http://patchwork.ozlabs.org/api/series/501056/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=501056","date":"2026-04-22T17:47:28","name":"WIP: libstdc++: constrain std::atomic's default constructor","version":1,"mbox":"http://patchwork.ozlabs.org/series/501056/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/covers/2226647/comments/","headers":{"Return-Path":"<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":["incoming@patchwork.ozlabs.org","gcc-patches@gcc.gnu.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","gcc-patches@gcc.gnu.org"],"Authentication-Results":["legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=2620:52:6:3111::32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)","sourceware.org; dmarc=none (p=none dis=none)\n header.from=forge-stage.sourceware.org","sourceware.org;\n spf=pass smtp.mailfrom=forge-stage.sourceware.org","server2.sourceware.org;\n arc=none smtp.remote-ip=38.145.34.39"],"Received":["from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g16G14Sxdz1y2d\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 23 Apr 2026 03:50:49 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id C03014B920FA\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 17:50:47 +0000 (GMT)","from forge-stage.sourceware.org (vm08.sourceware.org [38.145.34.39])\n by sourceware.org (Postfix) with ESMTPS id 1E9854B9DB63\n for <gcc-patches@gcc.gnu.org>; Wed, 22 Apr 2026 17:48:22 +0000 (GMT)","from forge-stage.sourceware.org (localhost [IPv6:::1])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256)\n (No client certificate requested)\n by forge-stage.sourceware.org (Postfix) with ESMTPS id E294042BF4\n for <gcc-patches@gcc.gnu.org>; Wed, 22 Apr 2026 17:48:21 +0000 (UTC)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org C03014B920FA","OpenDKIM Filter v2.11.0 sourceware.org 1E9854B9DB63"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 1E9854B9DB63","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 1E9854B9DB63","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776880102; cv=none;\n b=J56dODkNy2HqD4sPW9xJnuI3HBxGrqnfhzjHW1/4N5gzGzQmOuMji3Sabwsk6Oaww/mOzRd6DwKpBn8w4TroJfqVIBmS60AKGJyMA+DWnWjmxlzgRKVuF9dUN1LQGebl2Lp+LCuzFKQ8lAnF+tXA1qVgRu2A5orX2zxQDhYASy4=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776880102; c=relaxed/simple;\n bh=gPiTd7DUxrvXZDNrqVoCmBYbDojEJVnoHUe8IlB5+xw=;\n h=From:Date:Subject:To:Message-ID;\n b=ICdeG/VvoaiMsuXzGF8a1Dtoe5aZR9S10e9/0FkZj+H4TCT4rY+lCpdg4Hx/gA2feAYfeLghn+VqvDeTNoaXsSUFrRqEuvtvrSq6DkTkp9E7VX8h5OT5Ohs0mwRKMAM+3K7VpKnHOuhdkUT0KxwU+ostwCKBsivfTh+iJpGpyxk=","ARC-Authentication-Results":"i=1; server2.sourceware.org","From":"peppe via Sourceware Forge <forge-bot+peppe@forge-stage.sourceware.org>","Date":"Wed, 22 Apr 2026 17:47:27 +0000","Subject":"[PATCH v1 0/1] WIP: libstdc++: constrain std::atomic's default\n constructor","To":"gcc-patches mailing list <gcc-patches@gcc.gnu.org>","Message-ID":"\n <bmm.hhunfc5mlg.gcc.gcc-TEST.peppe.36.1.0@forge-stage.sourceware.org>","X-Mailer":"batrachomyomachia","X-Requested-Reviewer":"redi","X-Pull-Request-Organization":"gcc","X-Pull-Request-Repository":"gcc-TEST","X-Pull-Request":"https://forge.sourceware.org/gcc/gcc-TEST/pulls/36","X-BeenThere":"gcc-patches@gcc.gnu.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Gcc-patches mailing list <gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>","List-Archive":"<https://gcc.gnu.org/pipermail/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-request@gcc.gnu.org?subject=help>","List-Subscribe":"<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>","Reply-To":"gcc-patches mailing list <gcc-patches@gcc.gnu.org>,\n peppe@noreply.localhost","Errors-To":"gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org"},"content":"Hi gcc-patches mailing list,\npeppe via Sourceware Forge <forge-bot+peppe@forge-stage.sourceware.org> has requested that the following forgejo pull request\nbe published on the mailing list.\n\nCreated on: 2025-03-06 10:32:34+00:00\nLatest update: 2025-08-13 03:36:59+00:00\nChanges: 0 changed files, 0 additions, 0 deletions\nHead revision: peppe/gcc-TEST ref refs/pull/36/head commit 50befa32f7cc696850607d9c09b81a4de529597a\nBase revision: gcc/gcc-TEST ref trunk commit e6e7b477bbdbfb3fee6b44087a59f94fd1e2c7a3 r15-7897-ge6e7b477bbdbfb\nMerge base: e6e7b477bbdbfb3fee6b44087a59f94fd1e2c7a3\nFull diff url: https://forge.sourceware.org/gcc/gcc-TEST/pulls/36.diff\nDiscussion:  https://forge.sourceware.org/gcc/gcc-TEST/pulls/36\nRequested Reviewers: redi\n\nThis commit implements the proposed resolution to LWG4169, which is\nto constrain std::atomic<T>'s default constructor based on whether\nT itself is default constructible.\n\nAt the moment, std::atomic<T>'s primary template in libstdc++ has a\ndefaulted default constructor. Value-initialization of the T member\n(since C++20 / P0883R2) is done via a NSDMI (= T()).\n\nGCC already considers the defaulted constructor constrained/deleted,\nhowever this behavior is non-standard (see the discussion in PR116769):\nthe presence of a NSDMI should not make the constructor unavailable to\noverload resolution/deleted ([class.default.ctor]/2.5 does not apply).\nWhen using libstdc++ on Clang, this causes build issues as the\nconstructor is *not* deleted there -- the interpretation of\n[class.default.ctor]/4 seems to match Clang's behavior.\n\nTherefore, although there would be \"nothing to do\" with GCC+libstdc++,\nthis commit changes the code as to stop relying on the GCC language\nextension. std::atomic's defaulted default constructor is changed to be\na non-defaulted one, with a constraint added as per LWG4169;\nvalue-initialization of the data member is moved from the NSDMI to the\nmember init list. The new signature matches the one in the Standard as\nper [atomics.types.operations]/1.\n\nA test that explictly instantiated std::atomic with a non-default\nconstructible type needed to be amended. Such an instantiation would\ninstantiate all member functions (as per [temp.explicit]/9), including\nthe default constructor, which now triggers a hard error when built in\npre-C++20 modes.\n\nIn its place I've instead added a couple of static_asserts checking that\nstd::atomic is default constructible even with a non-default\nconstructible T (in pre-C++20 modes), or is not default constructible\nat all (since C++20).\n\n```\nlibstdc++-v3/ChangeLog:\n\n\t* include/std/atomic (atomic): Turn the defaulted default\n\tconstructor in a non-defaulted one, constraining it as per\n\tLWG4169; remove the NSDMI for the _M_i member.\n\t(_GLIBCXX20_INIT): Drop the macro, as it is not needed any more.\n\t* testsuite/29_atomics/atomic/69301.cc: Restrict the explicit\n\tclass instantation only to C++ >= 20 modes; it would otherwise\n\tcause a hard error. Add a new test.\n\t* testsuite/29_atomics/atomic/cons/value_init.cc: Add a new test.\n```\n\n\nChanged files:\n- A: libstdc++-v3/testsuite/29_atomics/atomic/cons/trivial.cc\n- M: libstdc++-v3/include/bits/version.def\n- M: libstdc++-v3/include/bits/version.h\n- M: libstdc++-v3/include/std/atomic\n- M: libstdc++-v3/testsuite/29_atomics/atomic/69301.cc\n\n\nGiuseppe D'Angelo (1):\n  libstdc++: constrain std::atomic's default constructor\n\n libstdc++-v3/include/bits/version.def         |  1 +\n libstdc++-v3/include/bits/version.h           |  2 +-\n libstdc++-v3/include/std/atomic               | 22 +++++-----\n .../testsuite/29_atomics/atomic/69301.cc      |  2 +\n .../29_atomics/atomic/cons/trivial.cc         | 41 +++++++++++++++++++\n 5 files changed, 57 insertions(+), 11 deletions(-)\n create mode 100644 libstdc++-v3/testsuite/29_atomics/atomic/cons/trivial.cc"}