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 ESMTP id 7FC52395B45B for ; Tue, 13 Jul 2021 14:08:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7FC52395B45B Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-584-gPSUpRXxOhS-McTSPdNgNA-1; Tue, 13 Jul 2021 10:08:53 -0400 X-MC-Unique: gPSUpRXxOhS-McTSPdNgNA-1 Received: by mail-wr1-f72.google.com with SMTP id p4-20020a5d63840000b0290126f2836a61so8851202wru.6 for ; Tue, 13 Jul 2021 07:08:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=VoHypyHPOlwMeCynjjGkWY4UMqKhQyb5mTQu/D3dgoI=; b=HjTNGYc69JA7wZpzLC1yVB6VMv/e28k1ltcpA+5exFErT3l3MJQP8FvlCLCBzQ7X+g zM4Ig2f4TfSm1Gl7o1b9ySSIsiiZoBDeWb//DI4aXncu8M3CxZIc4GGZSXj2amCJL+oi 1ghfEACiW9DZq4eZzHsUngt6lwhTCnW1Bi52QtdfJ6S3r0+Nx2O1WtPLC6i+qptULi/Q gw32zzV5bU+c4sAFHRGp9SAPIsBfwb2vSPmnfDGrbTUsbLGVYxnhObNjA3+Tv7xDLBt3 O3utXD3w8EALsRgFZb9+qdXVcViG+SS8w59IveqnD5ObI90jb9sDNSPpcMq0fiGzSKjW FtYA== X-Gm-Message-State: AOAM533SP7WpyC+rR1vrmqAiawDGEc5Mpje158w11qS7XzoN/4eAAepi wQN9CuUgrUoIeW0mMvpP/x9cUJG7UbjpRMBdKcJAUQtpjmLOBt/h3vgs5LegGxJIlJ3jGglD4ep 6tHbwv8DWk1RkCrAZZoevRqpBFJJukq5bnA== X-Received: by 2002:adf:e7c6:: with SMTP id e6mr5968833wrn.221.1626185332269; Tue, 13 Jul 2021 07:08:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWp5r5/+tJsU7xl0MA7+wwLvioCnZ+WdjXGSQMqAtra2cxlacvFJZeHAUE7/Z60n8b4meLOsZyo/nt0bF6mPY= X-Received: by 2002:adf:e7c6:: with SMTP id e6mr5968794wrn.221.1626185332050; Tue, 13 Jul 2021 07:08:52 -0700 (PDT) MIME-Version: 1.0 References: <91545a73-12af-33b2-c6e7-119b5a21de60@gmail.com> <4d503394-4e82-1d36-41ca-34315042775b@redhat.com> <49569f1d-9856-55c7-b9e9-578bbd7c7b7a@gmail.com> <390c6652-0a1f-e8c4-d70d-56ced2f7b0fb@gmail.com> In-Reply-To: From: Jonathan Wakely Date: Tue, 13 Jul 2021 15:08:40 +0100 Message-ID: Subject: Re: [PING][PATCH] define auto_vec copy ctor and assignment (PR 90904) To: Richard Biener Cc: Martin Sebor , Jason Merrill , gcc-patches X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Jul 2021 14:08:59 -0000 On Mon, 12 Jul 2021 at 12:02, Richard Biener wrote: > Somebody with more C++ knowledge than me needs to approve the > vec.h changes - I don't feel competent to assess all effects of the change. They look OK to me except for: -extern vnull vNULL; +static constexpr vnull vNULL{ }; Making vNULL have static linkage can make it an ODR violation to use vNULL in templates and inline functions, because different instantiations will refer to a different "vNULL" in each translation unit. The extern object avoids that problem. It probably won't cause real problems in practice but it's still technically UB. If avoiding the extern variable is desirable, you can make it inline when compiled by a C++17 compiler (such as GCC 11): #if __cpp_inline_variables inline constexpr vnull vNULL{ }; #else extern const vnull vNULL; #endif and then define it in vec.c: #if ! __cpp_inline_variables const vnull vNULL{ }; #endif