From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 94FFD3858002 for ; Wed, 8 Dec 2021 23:47:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 94FFD3858002 Received: from mail-yb1-f197.google.com (mail-yb1-f197.google.com [209.85.219.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-592-tMjJbUKCObycr_3FhQi8AA-1; Wed, 08 Dec 2021 18:47:24 -0500 X-MC-Unique: tMjJbUKCObycr_3FhQi8AA-1 Received: by mail-yb1-f197.google.com with SMTP id h5-20020a255f45000000b005ffd939127bso7143293ybm.10 for ; Wed, 08 Dec 2021 15:47:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=QYQDgVJLb6XHEn1aSqguXJmzd13UyAtj+0zxxClIZsc=; b=TPzFDzW1HcdcaD6eSWKQneIKSqDSQSzAON1nRvY9W+HLlUC7CeNaWby5ZYtrALCi9W vAoM2GW/JPx7Z9EDxoVMKHahz84Pqi98DkZG5aVqw+zgAzgPHmbUy6iDhHsmbqd0le5J kjz8zqtBLFu0sbZcoiXxwqjefzYA/pPcZJUslv5Yr70M+VOKeVCoxaJvrRkvQy7AT3Z4 HqC9lI1QQlB+1ePODw0VWhd2B+t6pwTdZCqD5yLkWNEVhGyRq0oD1fUJ+fGPbFtiezrb P6LmTV1d2QwMmFqKB9fCbk3Ogh+uYC1B4lxxjCp/R0EYGKFSUxrwKVVyxo+vkC4yAAEh VV/Q== X-Gm-Message-State: AOAM532/BdKg4xDSwuvlOr3gA0IDqT8VttYuxpLEQT2THRscAY5YSEaI hxORtWaxRS0pY2GvFWMVpRhn1Xv7jD7phJN58FqiWu9kbPLc70wvmauQylR0RvIaaY4rTraHZtE ldEFwq7wQrAPerm669kOmljhf7cxC95Y= X-Received: by 2002:a25:bcc9:: with SMTP id l9mr2270263ybm.13.1639007244387; Wed, 08 Dec 2021 15:47:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJyZs0PwHWwJ+GVlBEVmYG0GfDs+N+dqwwWsFKpiqKoi+j/mz9BsShdW003dmv+arQexWu8XeUlBaxZd61AZYxU= X-Received: by 2002:a25:bcc9:: with SMTP id l9mr2270241ybm.13.1639007244166; Wed, 08 Dec 2021 15:47:24 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Jonathan Wakely Date: Wed, 8 Dec 2021 23:47:13 +0000 Message-ID: Subject: [committed] libstdc++: Fix undefined shift when _Atomic_word is 64-bit To: Rainer Orth Cc: Jonathan Wakely via Gcc-patches , "libstdc++" X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/mixed; boundary="00000000000092fcd705d2ab1cd0" X-Spam-Status: No, score=-14.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=unavailable autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Dec 2021 23:47:28 -0000 --00000000000092fcd705d2ab1cd0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 8 Dec 2021 at 19:27, Jonathan Wakely wrote: > > On Wed, 8 Dec 2021 at 19:21, Jonathan Wakely wrote: > > > > On Wed, 8 Dec 2021 at 19:17, Rainer Orth wrote: > > > > > > Hi Jonathan, > > > > > > > I've pushed this change to trunk now (it was posted and reviewed in > > > > stage 1, I just didn't get around to pushing it until now). > > > > > > > > The final version of the patch is attached to this mail. > > > > > > unfortunately, it breaks Solaris/SPARC bootstrap: > > > > > > In file included from /var/gcc/regression/master/11.4-gcc-gas/build/s= parc-sun-solaris2.11/sparcv9/libstdc++-v3/include/bits/shared_ptr.h:53, > > > from /var/gcc/regression/master/11.4-gcc-gas/build/s= parc-sun-solaris2.11/sparcv9/libstdc++-v3/include/memory:77, > > > from /vol/gcc/src/hg/master/local/libstdc++-v3/inclu= de/precompiled/stdc++.h:82: > > > /var/gcc/regression/master/11.4-gcc-gas/build/sparc-sun-solaris2.11/s= parcv9/libstdc++-v3/include/bits/shared_ptr_base.h: In member function 'voi= d std::_Sp_counted_base<_Lp>::_M_release() [with __gnu_cxx::_Lock_policy _L= p =3D __gnu_cxx::_S_atomic]': > > > /var/gcc/regression/master/11.4-gcc-gas/build/sparc-sun-solaris2.11/s= parcv9/libstdc++-v3/include/bits/shared_ptr_base.h:329:26: error: right ope= rand of shift expression '(1 << 64)' is greater than or equal to the precis= ion 64 of the left operand [-fpermissive] > > > 329 | =3D 1LL + (1LL << (__CHAR_BIT__ * sizeof(_Atomic_= word))); > > > | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~~~~~ > > > make[9]: *** [Makefile:1875: sparc-sun-solaris2.11/bits/stdc++.h.gch/= O2ggnu++0x.gch] Error 1 > > > > > > For 64-bit SPARC, _Atomic_word is long. > > > > Ah yes, so we need to disable this optimization. Patch coming up ... > > Gah, I remembered to check that: > > constexpr bool __double_word > =3D sizeof(long long) =3D=3D 2 * sizeof(_Atomic_word); > // The ref-count members follow the vptr, so are aligned to > // alignof(void*). > constexpr bool __aligned =3D __alignof(long long) <=3D alignof(void= *); > if _GLIBCXX17_CONSTEXPR (__lock_free && __double_word && __aligned) > > > But for C++11 and C++14 that is a normal runtime condition not > if-constexpr, so the undefined shift still gets compiled, even though > it can never be reached at runtime. Fixed like so. Tested sparc-sun-solaris2.11, pushed to trunk. --00000000000092fcd705d2ab1cd0 Content-Type: text/plain; charset="US-ASCII"; name="patch.txt" Content-Disposition: attachment; filename="patch.txt" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_kwy6g9i40 Y29tbWl0IGMxNWFhNDZjY2EwNjQ5YjY4NjEzZDMyOTJjZjcxYzdjYzU3ZWY3OGYKQXV0aG9yOiBK b25hdGhhbiBXYWtlbHkgPGp3YWtlbHlAcmVkaGF0LmNvbT4KRGF0ZTogICBXZWQgRGVjIDggMTk6 MzY6MjQgMjAyMQoKICAgIGxpYnN0ZGMrKzogRml4IHVuZGVmaW5lZCBzaGlmdCB3aGVuIF9BdG9t aWNfd29yZCBpcyA2NC1iaXQKICAgIAogICAgVGhlIGNoZWNrIGZvciBfQXRvbWljX3dvcmQgYmVp bmcgMzItYml0IGlzIGp1c3QgYSBub3JtYWwgcnVudGltZQogICAgY29uZGl0aW9uIGZvciBDKysx MSBhbmQgQysrMTQsIGJlY2F1c2UgaXQgZG9lc24ndCB1c2UgaWYtY29uc3RleHByLiBUaGF0CiAg ICBtZWFucyB0aGUgMUxMIDw8IChDSEFSX0JJVCAqIHNpemVvZihfQXRvbWljX3dvcmQpKSBleHBy ZXNzaW9uIGV4cGFuZHMgdG8KICAgIDFMTCA8PCA2NCBvbiBTb2xhcmlzLCB3aGljaCBpcyBpbGwt Zm9ybWVkLgogICAgCiAgICBUaGlzIGFkZHMgYW5vdGhlciBpbmRpcmVjdGlvbiBzbyB0aGF0IHRo ZSBzaGlmdCB3aWR0aCBpcyB6ZXJvIGlmIHRoZQogICAgY29kZSBpcyB1bnJlYWNoYWJsZS4KICAg IAogICAgbGlic3RkYysrLXYzL0NoYW5nZUxvZzoKICAgIAogICAgICAgICAgICAqIGluY2x1ZGUv Yml0cy9zaGFyZWRfcHRyX2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