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 D0FB8385E83E for ; Mon, 3 Jun 2024 19:08:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D0FB8385E83E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D0FB8385E83E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717441710; cv=none; b=cSrx1cB7oTpSmE2ELNS6n5gstZdm+CfbGTMEd/byqXSjA1Jzse/Jreqrr1v0Q1VVzDkXry2IsJRHjnJmGzzM4Rh2r9P56lNFfDqSXCT3PSJ7KWZmpwTwKDP6LFWo0fcrySvGD+n2SItdkjhUDXu0x+vJ3l4U5xXc72OwlGkVyeA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717441710; c=relaxed/simple; bh=KlctXAD5rsSi00LDgRwCkn+cNHZwKd/xTM5dmOHItEE=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=pXK3PapQ0Y3cqqBPu9GgkDaiuqc5NTb3+jV4HHIC7APyvYrtFVWMAlwH85kwHG4dbWo8PyFqt3TiE5mdMdkTDxQUsiWopzLoC2Ee8jjgcPfdFWaEcXIgOz6AQyVF/koM2T120kQyQhW8HC9R6Hut7XltPEBsYAJzqC5iC+09xkA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717441708; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=B7/y18s28Kfap/3Nol/f9my/XZg0PjwDrPLuGz+FnCM=; b=Senzc6DGjrIsz84G2I7ai7ANcIeFwXzF7E0wO2aPAiffFZ5MK98MEpNBL/kQiHijI80GZ9 8oTZzzeyEfpZdpawlJN/ExvYBNb7hNWW4doVM3CxlSKhmVHJf3ZRc+BrOfIZ9yL0sokt5e a/BFs4gEZrPy5g4ESNFdGsKaS1gBiOs= Received: from mail-yb1-f199.google.com (mail-yb1-f199.google.com [209.85.219.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-94-vbqlLg_nOjmFrTLMwtW_UQ-1; Mon, 03 Jun 2024 15:08:27 -0400 X-MC-Unique: vbqlLg_nOjmFrTLMwtW_UQ-1 Received: by mail-yb1-f199.google.com with SMTP id 3f1490d57ef6-df7a6530373so8782159276.0 for ; Mon, 03 Jun 2024 12:08:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717441706; x=1718046506; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=B7/y18s28Kfap/3Nol/f9my/XZg0PjwDrPLuGz+FnCM=; b=hEqJqbtM848/sTqAp4C5/4fwyKN66o/gK2lORYAgL7H98ug4+qzm6zGAmZduJajlmI E+nwg2pspSKsUl/bFUYDii/OUazbCvtWZpBsj4K9xt3nROvO6CoEMNXTIOBZdYHgGQK7 FYeCPWUqSJmO4mzaInG+XbgIUiwFhfBbUKi2ZudzxdJYfQICka0SF9S6+Pfe0zFTebKW vyKXKWvSHWhEo+dAZnxAlKRxLn5YVOQMTQKDv7qXp1TfkJ/tSqs5isvH3PZufJyuPP2d GB8/V69EmHLLAtU55JPjZRvdLCK6+Su2g+ek0CCHQUY3em9INt/50MMQrME2dTOep6X1 fyFg== X-Forwarded-Encrypted: i=1; AJvYcCVyLhlpFbVRq+WMRy/TDddIgSdbIF5s8QUzLGrrfOeLjOo/gt/498hy7CvtZGk9rQa0f3UlXGtWvyEyDCWFe4HS3lcJUkudMA== X-Gm-Message-State: AOJu0YyqDGJteK64OD0+4zty6S/LJVkGyrDombI5Hs60+QPvTKoP9EQt 7x5OfiUGGaib0NmtSYKP7/p8KWClIrODnRYhL29HV/ftdWXTaL+Snj5p92qJ2agfOtJINw/Ws7G 53sAwF7IIiiBk6EffJRt0zXB4UlD31nkSo78NfXWoRSYb21Cr3yXnw9pNQwsksTEW59ESJIAWkF RrHkN74Fzr9ayQQBYgpioGCibgEJ0PwQ== X-Received: by 2002:a25:820d:0:b0:df4:ec88:a713 with SMTP id 3f1490d57ef6-dfab8b32491mr472215276.32.1717441706551; Mon, 03 Jun 2024 12:08:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGffZppgVhgf1J11EiPkvB1TuZpfbnzVhDvErrSoAJHFNZSzz+rkZGOOFd8HEuxHeQhdKZclVZdqnaUSWr7UKs= X-Received: by 2002:a25:820d:0:b0:df4:ec88:a713 with SMTP id 3f1490d57ef6-dfab8b32491mr472196276.32.1717441706102; Mon, 03 Jun 2024 12:08:26 -0700 (PDT) MIME-Version: 1.0 References: <4657346e-3046-424a-be1d-32a7eaecae32@gmail.com> <67574fa4-25e9-42a4-8025-1fc88f5a71ce@gmail.com> In-Reply-To: <67574fa4-25e9-42a4-8025-1fc88f5a71ce@gmail.com> From: Jonathan Wakely Date: Mon, 3 Jun 2024 20:08:10 +0100 Message-ID: Subject: Re: [PATCH] Fix -Wstringop-overflow warning in 23_containers/vector/types/1.cc PR109849 To: =?UTF-8?Q?Fran=C3=A7ois_Dumont?= Cc: "libstdc++" , gcc-patches X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_NUMSUBJECT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no 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 Mon, 3 Jun 2024 at 18:46, Fran=C3=A7ois Dumont wr= ote: > > > On 03/06/2024 18:20, Jonathan Wakely wrote: > > On Mon, 3 Jun 2024 at 05:56, Fran=C3=A7ois Dumont wrote: > >> I hadn't try to make my patch as limited as possible to fix the proble= m, > >> indeed. > >> > >> libstdc++: Fix -Wstringop-overflow warning coming from std::vect= or > >> [PR109849] > >> > >> libstdc++-v3/ChangeLog: > >> > >> PR libstdc++/109849 > >> * include/bits/vector.tcc > >> (std::vector<>::_M_range_insert(iterator, _FwdIt, _FwdIt= , > >> forward_iterator_tag)): Add __builtin_unreachable > >> expression to tell > >> the compiler that the allocated buffer is large enough t= o > >> receive current > >> elements plus the range to insert. > >> > >> Tested under Linux x64, ok to commit ? > > Does the !__builtin_constant_p(__len) in this version do anything? > > > > If it's a constant, then the compiler can already provide it's in > > range, so the __builtin_unreachable() is redundant, but doesn't do any > > harm. > > > Yes, it prevents some constexpr test failure because > __builtin_unreachable is not a constexpr (at least not for some C++ > Standard versions). > > But it wasn't a nice way to avoid this regression. Here is another > proposal that activate the __builtin_unreachable only for pre-c++11 > modes. C++03 had no problem neither but I haven't found any occurrence > of __cplusplus checks against the C++03 version so I prefer not to add an= y. > > libstdc++: Fix -Wstringop-overflow warning coming from std::vector > [PR109849] > > libstdc++-v3/ChangeLog: > > PR libstdc++/109849 > * include/bits/vector.tcc > (std::vector<>::_M_range_insert(iterator, _FwdIt, _FwdIt, > forward_iterator_tag))[__cplusplus < 2011103L]: Add > __builtin_unreachable > expression to tell the compiler that the allocated buffer > is large enough to > receive current elements plus the elements of the range to > insert. > > Ok to commit ? OK for trunk and gcc-14, thanks.