From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 91899 invoked by alias); 28 Jun 2018 11:32:25 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 91854 invoked by uid 89); 28 Jun 2018 11:32:19 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qt0-f179.google.com Received: from mail-qt0-f179.google.com (HELO mail-qt0-f179.google.com) (209.85.216.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 28 Jun 2018 11:32:17 +0000 Received: by mail-qt0-f179.google.com with SMTP id y20-v6so4338100qto.8 for ; Thu, 28 Jun 2018 04:32:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=VEg7zdtQgVHhFWYpq5wpnUPCzTPZhDkU9/fSxIOuac8=; b=TFo6Y8Xc1iNtOdvW3UavxPeY0PASioTmSl/FsQgydAtrQVHOHz6yfAKynSzGzwM36A 78561DQH1Cgts5vNtW/2tgo9fEz65yLEKWhcw1Ui9hWwJ3i+Nck2CXyGf8yDWrPJvd9j YOYLB3ed6PwfwicQKZScnnWySoHOCZa0L/FFJqv0jP2/5qE9tHfJe1WV7SzYbREBPrif XI3EfqygfZOx3xn+z/OUNXoAGx6ChtVOkjnpTHA+yKbIAQkn8gZFOdthilIDnY4w+cPF RtCYwOn5+JdBk1/SlYpRVPXARHgsjN9DW/Px3ooupdoo15FKXt5frou7llW0HA6L3LxU wqdA== MIME-Version: 1.0 Received: by 2002:ac8:4301:0:0:0:0:0 with HTTP; Thu, 28 Jun 2018 04:32:15 -0700 (PDT) In-Reply-To: References: From: Csaba Raduly Date: Thu, 28 Jun 2018 11:49:00 -0000 Message-ID: Subject: Re: Wdeprecated-copy on system type To: Jonathan Wakely Cc: "gcc@gcc.gnu.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-SW-Source: 2018-06/txt/msg00283.txt.bz2 On Wed, Jun 27, 2018 at 1:28 PM, Jonathan Wakely wrote: > Your mail is off-topic on this list, it would be appropriate on the > gcc-help list, or in Bugzilla if you want to report a bug. > > > On Wed, 27 Jun 2018 at 11:27, Csaba Raduly wrote: (snip) >> 1. Why is a warning emitted only for the const srange? > > Because line 16 doesn't use the sub_range copy constructor, it calls > this instead: > > template< class ForwardRange2 > > sub_range( > ForwardRange2& r, > BOOST_DEDUCED_TYPENAME ::boost::enable_if< > is_compatible_range > >::type* =3D 0 > ) > : base(impl::adl_begin(r), impl::adl_end(r)) > { > } > > This might be a Boost bug, albeit a harmless one. IMHO the template > constructor should be constrained so it isn't used for copying > non-const lvalues. So the fact that there's no warning for the non-const version is in fact a bug in Boost, right? (It's still like that in latest, not yet released Boost 1.68). This sounds like a "greedy template" you spoke about at ACCUcon 2018. > > >> 2. Shouldn't boost be exempt from this warning, given that it's >> included from a system directory (/usr/include) ? > > Yes, it probably should, but see below. > >> Shouldn't the "implicitly declared copy constructor" error be located >> at the class definition (boost header), rather than where it's being >> called (the call which does pass-by-value) ? > > The warning is only issued at the point where the implicit definition > is needed, to avoid issuing warnings when the object is never copied. > It's needed at the call site in your code, not in the system header > (well, it might also be needed in the boost headers, but those > warnings are probably suppressed). Of course the warning should only be emitted when such a constructor/assignment is used. Still, in my naive opinion, such a constructor is declared (implicitly) in the class (sub_range). The message at the point of use should be something similar to the "instantiated from" message when there's an error inside a template. Something like: /usr/include/boost/range/sub_range.hpp:???: implicitly-declared =E2=80=98co= nstexpr boost::sub_range>::sub_range(const boost::sub_range >&)=E2=80=99 is deprecated [-Werror=3Ddeprecated-copy] /usr/include/boost/range/sub_range.hpp:259:20: note: because REASONS subra.cpp:7:6: note: used when initializing argument 1 of =E2=80=98void f= unc(srange)=E2=80=99 > > But I agree that if the class is defined in a system header you can't > change the code, so the warning is not very helpful. Please report a > bug, https://gcc.gnu.org/bugs/ Csaba --=20 You can get very substantial performance improvements by not doing the right thing. - Scott Meyers, An Effective C++11/14 Sampler So if you're looking for a completely portable, 100% standards-conformat way to get the wrong information: this is what you want. - Scott Meyers (C++TDa= WYK)