220 14507 <1836076.4N961PB4hM@tjmaciei-mobl4> article
Path: news.gmane.org!not-for-mail
From: Thiago Macieira <thiago@macieira.org>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: Range-based if
Date: Wed, 12 Nov 2014 13:34:08 -0800
Lines: 37
Approved: news@gmane.org
Message-ID: <1836076.4N961PB4hM@tjmaciei-mobl4>
References: <CADbh+eQCaTPArs7YBUg9mYwrnJ2Gu3SRAfqUbPiLscpyxV8JqQ@mail.gmail.com> <1475323.QBNzPAHAPV@tjmaciei-mobl4> <CADbh+eTq5TFWRdOz84YTc+Go03cOzr-05B4na=wwq2mkdXJVzQ@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
X-Trace: ger.gmane.org 1415828089 30038 80.91.229.3 (12 Nov 2014 21:34:49 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 12 Nov 2014 21:34:49 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCB4TK757YBRB4FER6RQKGQEMLMBVPQ@isocpp.org Wed Nov 12 22:34:44 2014
Return-path: <std-proposals+bncBCB4TK757YBRB4FER6RQKGQEMLMBVPQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-wg0-f69.google.com ([74.125.82.69])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCB4TK757YBRB4FER6RQKGQEMLMBVPQ@isocpp.org>)
	id 1XofYn-0007Yp-PS
	for gclcip-std-proposals@m.gmane.org; Wed, 12 Nov 2014 22:34:41 +0100
Original-Received: by mail-wg0-f69.google.com with SMTP id l18sf7146677wgh.0
        for <gclcip-std-proposals@m.gmane.org>; Wed, 12 Nov 2014 13:34:41 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:from:to:subject:date:message-id:user-agent
         :in-reply-to:references:mime-version:content-type:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe;
        bh=9ra/uANPxfckuna0/E6p+7g8xBeqaHUUQv0r10kBwIY=;
        b=eBkRkcsNLhX3KSjxTL7/CmJpf9kBzkbpvIXyyhiE3G38eIDSfxHQv7EZK8L+j2Hivt
         nwHCfHMB+Bzsl2qHhvmMHtz9QHMSW3xxzoLYJW6kvnFNjs5iX9Mh88iXych+2DGoFYDl
         OJWFwsd7DtI+JMlvcmIVI9WMvGOawOdrw3ML0UFsV7PuKfbybjSXkfoIV/Oowm6Jql/X
         c9jEIxZlS4YpCIMZrSnJcVszru1mE1Pr4Un35cVy9zcIy1bZgYMi2wMacdgSy2OhDbYH
         i57cd/OKTXeHIpq5Z5oL0AZUaBTFxcDuAhBXWXadhO3ub+eFqBmIqFPpmrwqkxjsCMeC
         lGKQ==
X-Gm-Message-State: ALoCoQm7F4Mg4MNYPgNwpGXNMKBIBj2zdHryvSlzsLQy1ZHp6mv7j3SGZmNsOv9Fxo/FfZnx5qbu
X-Received: by 10.112.188.199 with SMTP id gc7mr3297998lbc.6.1415828081510;
        Wed, 12 Nov 2014 13:34:41 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.180.88.194 with SMTP id bi2ls436312wib.53.canary; Wed, 12 Nov
 2014 13:34:40 -0800 (PST)
X-Received: by 10.180.75.38 with SMTP id z6mr8623289wiv.81.1415828080291;
        Wed, 12 Nov 2014 13:34:40 -0800 (PST)
Original-Received: from gondolin.macieira.info (gondolin.macieira.info. [78.47.120.188])
        by mx.google.com with ESMTP id u13si41921215wjr.12.2014.11.12.13.34.40
        for <std-proposals@isocpp.org>;
        Wed, 12 Nov 2014 13:34:40 -0800 (PST)
Received-SPF: pass (google.com: domain of thiago@macieira.org designates 78.47.120.188 as permitted sender) client-ip=78.47.120.188;
Original-Received: from tjmaciei-mobl4.localnet (jfdmzpr06-ext.jf.intel.com [134.134.137.75])
	by gondolin.macieira.info (Postfix) with ESMTPSA id A37AB11BDCE
	for <std-proposals@isocpp.org>; Wed, 12 Nov 2014 13:34:38 -0800 (PST)
User-Agent: KMail/4.14.2 (Linux/3.16.6-2-desktop; KDE/4.14.2; x86_64; ; )
In-Reply-To: <CADbh+eTq5TFWRdOz84YTc+Go03cOzr-05B4na=wwq2mkdXJVzQ@mail.gmail.com>
X-Original-Sender: thiago@macieira.org
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of thiago@macieira.org designates 78.47.120.188 as permitted sender) smtp.mail=thiago@macieira.org
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <http://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:14507
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/14507>

On Wednesday 12 November 2014 00:50:42 Brent Friedman wrote:
> > I must be missing something: what wasn't reachable?
> 
> When you break on the first iteration, the code that advances the iterator
> can never be executed. We see this both for 'normal' for loops and for
> range-for loops.

So what? All the lines got executed. The fact that some assembly instructions 
did not get executed is not important. You should also report a missed 
optimisation opportunity bug report to your compiler, as it should be able to 
realise that the code will never loop and forego emitting the code that does 
the looping.

> It might be easy to say that this is something that vendors should fix, but
> I think that the warning is good and valuable as it is. By turning on this
> warning we've found a few places where the premature loop exit was actually
> unintentional. This is why I think a different control structure might be a
> better solution. It can make intent clearer to man and machine.

I agree I would have written the code differently, but I don't think 
overloading the if command for this purpose is the right thing to do. I'd 
reserve if (x : y) for some other, future purpose.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

-- 

--- 
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.
