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.129.124]) by sourceware.org (Postfix) with ESMTPS id CB50C3858C36 for ; Fri, 11 Nov 2022 17:55:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CB50C3858C36 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668189350; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=y0jKCpveREV0ZqDnVwPQZrJJS8DjrD4mKIfBqJIu0Do=; b=PqzWihY+H0Nfl6qJjfTt4ylZ42Jmdz6x6mtN3eJFvNkdJmoT5irY3M+OLQcb5Y4Kh15qsW X3JNdQMoYCsEfZ234YJcZUDuPWy/aXJnUJnG3OCR+CL5RxCZGPMO2n8PmZLJme+0o41lk6 7Ro5+D4z4GSV+udeEPiLDgphrbrIUeA= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-669-t3TmTPNDN9SBHQ6hAzq33g-1; Fri, 11 Nov 2022 12:55:49 -0500 X-MC-Unique: t3TmTPNDN9SBHQ6hAzq33g-1 Received: by mail-qk1-f200.google.com with SMTP id ay43-20020a05620a17ab00b006fa30ed61fdso5254266qkb.5 for ; Fri, 11 Nov 2022 09:55:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:references:message-id:in-reply-to:subject:cc:to:date :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=y0jKCpveREV0ZqDnVwPQZrJJS8DjrD4mKIfBqJIu0Do=; b=DuO73kK4x1heZr/WwQN8xgr54CATR8oExr0AafwzKuuRxA0iQiyw0JUfOPI3ShAbPv EgymkG/AYDd9fcNd6Cj6uIef2ni9jut2/Y1ZkvlelRrG4V2hS5HDmbP1hUqQKVLOFcc1 /GbdSzeE+XdrLBQKcsOldc2vcFXIcV3FrW+Rb52yrL6WslMXfxIREXLGi5pEUsn+xsk2 jQKMwmB4hlmb4nLPz6kzAgkhkeFU676M9vt0pTPwLXBZrFdQ2TiXgPhMORTZzMGeuiH2 +nKoZZevEkI6lb7zukR0zSrCH8zWq09XoBeVSUVYz8SkuXV642g4kp15ThmCwIZOr+5h LwYg== X-Gm-Message-State: ANoB5pmqJYGovMseU/GRy3IKe3S3frwnLbOxAxZ99jE/o1Ayi4GUmXmf oOLZRIRnXOJiUvh1OlFxATTfjQ6DIhk7/MBBzawqzhYcC4dhYxhlhSj5sxPneFCC3dYnce8WDyF QM/ae7n4X/m9NTXo= X-Received: by 2002:a37:5441:0:b0:6fa:7b74:1cee with SMTP id i62-20020a375441000000b006fa7b741ceemr2061611qkb.693.1668189348787; Fri, 11 Nov 2022 09:55:48 -0800 (PST) X-Google-Smtp-Source: AA0mqf6H5vZ5yct3H/aJov+0iAZoXBD3fp8gd1bA1DsJEGUjufKt38p+xvozB5dGVdKQzUJDIMlIjw== X-Received: by 2002:a37:5441:0:b0:6fa:7b74:1cee with SMTP id i62-20020a375441000000b006fa7b741ceemr2061587qkb.693.1668189348528; Fri, 11 Nov 2022 09:55:48 -0800 (PST) Received: from [192.168.1.130] (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id x7-20020ac84a07000000b0035badb499c7sm1583070qtq.21.2022.11.11.09.55.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Nov 2022 09:55:47 -0800 (PST) From: Patrick Palka X-Google-Original-From: Patrick Palka Date: Fri, 11 Nov 2022 12:55:46 -0500 (EST) To: Jonathan Wakely cc: Nathaniel Shead , libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: Re: [PATCH] libstdc++: Set active union member in constexpr std::string [PR103295] In-Reply-To: Message-ID: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-13.9 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_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Fri, 11 Nov 2022, Jonathan Wakely via Libstdc++ wrote: > On Fri, 11 Nov 2022 at 11:23, Nathaniel Shead via Libstdc++ > wrote: > > > > Hi, > > > > Below is a patch to fix std::string in constexpr contexts on Clang. This > > was originally fixed in the commits attached to PR103295, but a later > > commit 98a0d72a seems to have mistakenly undone this. > > > > Tested on x86_64-linux. Verified using clang-14 and clang-15 that the > > fix works. I haven't added anything to the test suite, since this issue > > is only detected by clang. > > > > This is my first time contributing, so please let me know if I've done > > anything wrong or missed something. Thanks! > > Thanks for the patch, I'll get this committed today. > > The only thing I had to fix was the indentation in the commit log. The > second line of the ChangeLog should be aligned with the * not the text > following it (so indented by a single tab). > > > > > > Nathaniel > > > > -- >8 -- > > > > Clang still complains about using std::string in constexpr contexts due > > to the changes made in commit 98a0d72a. This patch ensures that we set > > the active member of the union as according to [class.union.general] p6. > > > > libstdc++-v3/ChangeLog: > > > > PR libstdc++/103295 > > * include/bits/basic_string.h (_M_use_local_data): Set active > > member to _M_local_buf. > > > > Signed-off-by: Nathaniel Shead > > --- > > libstdc++-v3/include/bits/basic_string.h | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h > > index 9c2b57f5a1d..2790fd49b05 100644 > > --- a/libstdc++-v3/include/bits/basic_string.h > > +++ b/libstdc++-v3/include/bits/basic_string.h > > @@ -352,8 +352,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 > > { > > #if __cpp_lib_is_constant_evaluated > > if (std::is_constant_evaluated()) > > - for (_CharT& __c : _M_local_buf) > > - __c = _CharT(); > > + for (size_type i = 0; i <= _S_local_capacity; ++i) > > + _M_local_buf[i] = _CharT(); Just a minor nit, but we should probably uglify i to __i here. > > #endif > > return _M_local_data(); > > } > > -- > > 2.34.1 > > > >