From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x231.google.com (mail-oi1-x231.google.com [IPv6:2607:f8b0:4864:20::231]) by sourceware.org (Postfix) with ESMTPS id 679EC3858C50 for ; Sat, 30 Sep 2023 19:30:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 679EC3858C50 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-oi1-x231.google.com with SMTP id 5614622812f47-3af5b5d7f16so2924623b6e.0 for ; Sat, 30 Sep 2023 12:30:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1696102210; x=1696707010; darn=gcc.gnu.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=O2iwgtNu017M1eCQEYasQhEIR2AtYwrtukO7w/v+tgI=; b=pDSADaZMScphMOQP/+CP53VDUYnc/vW8qygi/CY9FxSi/2D+e3hHwZdD9lnV2jb+kw TJ5zKz6jEz4QQL2nDevA95N3FMPFUpBJ9Q8zCcUTqrI+IubMc8PjD59a0CosCFd1U6aD PhoNm0vDsRZF+Yx+Q3v7TL75HUSTmiKSb5BQc/gRODuAThOsEyiTdwEuQTncWtsB14Uj fKpYammJpcu+Lh/jjwgImqyhk0Rou2oSa6Zxge1AY6S/V7dXMaLNtPFa7SnLrbdrKdPM 8khldA3EZaLOG/XGJ8LfJKNEWLEjhGhlEo79ZpYtmolFNOasIhqg1m5LuRKo2vIKM0hH PLeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696102210; x=1696707010; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=O2iwgtNu017M1eCQEYasQhEIR2AtYwrtukO7w/v+tgI=; b=W0CVEU2M0FMLA1IlhlZWWD9bF6mZSTKQjcnK26Y2ugI6DXIXXu6rTWKbkuQadCmCEQ i6K5zr8ElA+m851WTgvpbKse+pGVn9+gcftsV5v47L8J2XJmzB8Cf5byNzOpWvqzeNMc /DqvUO46nojDIKzJzvgj0iT6wc4b3gheJiOZjJjNDhD4+CHihWL40d5XHv904fmhxzP2 zdi9mlAtQHKnx/fhOhayTMG4ZiynNqfZRAIQCrzpYJgQvaAgq7927zIZghy3W1E3KDzc fyipmhk9Bla2uZXh44RLB/K78KZEbsHuRsmXHf6Gu+zv4EwlUAlqdgzgevZvGH2ZFfg0 zgsw== X-Gm-Message-State: AOJu0YzBZXMqn8UTURbNR+zY4Yw25xHTdZOuE++0NhHBKnyuZWFo+/YW ZzObYU6xcAzj61dijLljhajj6A== X-Google-Smtp-Source: AGHT+IF+DIV9GyZhUQXDerw/RGgp6JWzsP+HF2bZOfsVaB5TatJ0Q8t2THZkRWMFfC8OsSutALLltQ== X-Received: by 2002:a54:489a:0:b0:3ae:4cab:526a with SMTP id r26-20020a54489a000000b003ae4cab526amr8246954oic.14.1696102210503; Sat, 30 Sep 2023 12:30:10 -0700 (PDT) Received: from ?IPV6:2601:647:5700:6860:9736:feb8:4ec9:b556? ([2601:647:5700:6860:9736:feb8:4ec9:b556]) by smtp.gmail.com with ESMTPSA id m22-20020a637116000000b00577e62e13c5sm12308700pgc.32.2023.09.30.12.30.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 30 Sep 2023 12:30:10 -0700 (PDT) Message-ID: <2803cc5e-054a-8e81-37a2-05dbdec95422@rivosinc.com> Date: Sat, 30 Sep 2023 12:30:05 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH] vec.h: Guard most of static assertions for GCC >= 5 Content-Language: en-US To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org, rguenther@suse.de, jwakely@redhat.com References: From: Patrick O'Neill In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,KAM_NUMSUBJECT,KAM_SHORT,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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: Hi Jakub, A follow-up commit of yours (9d249b7e31e) is causing bootstrap failures for riscv*-*-* targets. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111649 Patrick On 9/29/23 03:42, Jakub Jelinek wrote: > Hi! > > As reported by Jonathan on IRC, my vec.h patch broke build with GCC 4.8.x > or 4.9.x as system compiler, e.g. on CFarm. > The problem is that while all of > std::is_trivially_{destructible,copyable,default_constructible} traits > are in C++, only std::is_trivially_destructible has been implemented in GCC > 4.8, the latter two were added only in GCC 5. > Only std::is_trivially_destructible is the really important one though, > which is used to decide what pop returns and whether to invoke the > destructors or not. The rest are solely used in static_asserts and as such > I think it is acceptable if we don't assert those when built with GCC 4.8 > or 4.9, anybody doing bootstrap from those system compilers or doing builds > with newer GCC will catch that. > > So, the following patch guards those for 5+. > If we switch to C++14 later on and start requiring newer version of system > GCC as well (do we require GCC >= 5 which claims the last C++14 language > features, or what provides all C++14 library features, or GCC >= 6 which > uses -std=c++14 by default?), this patch then can be reverted. > > Ok for trunk? > > 2023-09-29 Jakub Jelinek > > * vec.h (quick_insert, ordered_remove, unordered_remove, > block_remove, qsort, sort, stablesort, quick_grow): Guard > std::is_trivially_{copyable,default_constructible} and > vec_detail::is_trivially_copyable_or_pair static assertions > with GCC_VERSION >= 5000. > (vec_detail::is_trivially_copyable_or_pair): Guard definition > with GCC_VERSION >= 5000. > > --- gcc/vec.h.jj 2023-09-29 10:59:09.830551963 +0200 > +++ gcc/vec.h 2023-09-29 12:29:32.676428677 +0200 > @@ -1086,7 +1086,12 @@ vec::quick_insert (unsig > { > gcc_checking_assert (length () < allocated ()); > gcc_checking_assert (ix <= length ()); > +#if GCC_VERSION >= 5000 > + /* GCC 4.8 and 4.9 only implement std::is_trivially_destructible, > + but not std::is_trivially_copyable nor > + std::is_trivially_default_constructible. */ > static_assert (std::is_trivially_copyable ::value, ""); > +#endif > T *slot = &address ()[ix]; > memmove (slot + 1, slot, (m_vecpfx.m_num++ - ix) * sizeof (T)); > *slot = obj; > @@ -1102,7 +1107,9 @@ inline void > vec::ordered_remove (unsigned ix) > { > gcc_checking_assert (ix < length ()); > +#if GCC_VERSION >= 5000 > static_assert (std::is_trivially_copyable ::value, ""); > +#endif > T *slot = &address ()[ix]; > memmove (slot, slot + 1, (--m_vecpfx.m_num - ix) * sizeof (T)); > } > @@ -1150,7 +1157,9 @@ inline void > vec::unordered_remove (unsigned ix) > { > gcc_checking_assert (ix < length ()); > +#if GCC_VERSION >= 5000 > static_assert (std::is_trivially_copyable ::value, ""); > +#endif > T *p = address (); > p[ix] = p[--m_vecpfx.m_num]; > } > @@ -1164,13 +1173,16 @@ inline void > vec::block_remove (unsigned ix, unsigned len) > { > gcc_checking_assert (ix + len <= length ()); > +#if GCC_VERSION >= 5000 > static_assert (std::is_trivially_copyable ::value, ""); > +#endif > T *slot = &address ()[ix]; > m_vecpfx.m_num -= len; > memmove (slot, slot + len, (m_vecpfx.m_num - ix) * sizeof (T)); > } > > > +#if GCC_VERSION >= 5000 > namespace vec_detail > { > /* gcc_{qsort,qsort_r,stablesort_r} implementation under the hood > @@ -1189,6 +1201,7 @@ namespace vec_detail > : std::integral_constant::value > && std::is_trivially_copyable::value> { }; > } > +#endif > > /* Sort the contents of this vector with qsort. CMP is the comparison > function to pass to qsort. */ > @@ -1197,7 +1210,9 @@ template > inline void > vec::qsort (int (*cmp) (const void *, const void *)) > { > +#if GCC_VERSION >= 5000 > static_assert (vec_detail::is_trivially_copyable_or_pair ::value, ""); > +#endif > if (length () > 1) > gcc_qsort (address (), length (), sizeof (T), cmp); > } > @@ -1210,7 +1225,9 @@ inline void > vec::sort (int (*cmp) (const void *, const void *, void *), > void *data) > { > +#if GCC_VERSION >= 5000 > static_assert (vec_detail::is_trivially_copyable_or_pair ::value, ""); > +#endif > if (length () > 1) > gcc_sort_r (address (), length (), sizeof (T), cmp, data); > } > @@ -1223,7 +1240,9 @@ inline void > vec::stablesort (int (*cmp) (const void *, const void *, > void *), void *data) > { > +#if GCC_VERSION >= 5000 > static_assert (vec_detail::is_trivially_copyable_or_pair ::value, ""); > +#endif > if (length () > 1) > gcc_stablesort_r (address (), length (), sizeof (T), cmp, data); > } > @@ -1396,7 +1415,9 @@ inline void > vec::quick_grow (unsigned len) > { > gcc_checking_assert (length () <= len && len <= m_vecpfx.m_alloc); > +#if GCC_VERSION >= 5000 > // static_assert (std::is_trivially_default_constructible ::value, ""); > +#endif > m_vecpfx.m_num = len; > } > > > Jakub >