220 37617 <ff48755d-ef5a-4f6d-7ac1-a408ac2ddfaa@gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Andrey Semashev <andrey.semashev@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Why do we need `volatile` in C++?
Date: Tue, 3 Apr 2018 17:48:55 +0300
Lines: 32
Approved: news@gmane.org
Message-ID: <ff48755d-ef5a-4f6d-7ac1-a408ac2ddfaa@gmail.com>
References: <044dfdd3-2313-4ce3-a5e2-3a23c1c0d678@isocpp.org>
 <CALDL7dE7cun_r-TjMmEMuFxeMTVhJ5E-8n=OfSGynO8-pEmE-g@mail.gmail.com>
 <CAHSYqdZfOer8tg6PsmpUn6-SCFgMGs2_Y6adcf_w+GNnWRa_+A@mail.gmail.com>
 <9bc32039-04fe-42cd-abc4-49040cf3a6dc@isocpp.org>
 <CAHSYqdbJzNpUAsH+P1PAPv2UO2v-KEFrecC36rMSwQuvKQHc1w@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"; format=flowed
X-Trace: blaine.gmane.org 1522766815 5003 195.159.176.226 (3 Apr 2018 14:46:55 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Tue, 3 Apr 2018 14:46:55 +0000 (UTC)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
 Thunderbird/52.7.0
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCXY5TXHWYJRBWNIR3LAKGQE7N3DPLQ@isocpp.org Tue Apr 03 16:46:51 2018
Return-path: <std-proposals+bncBCXY5TXHWYJRBWNIR3LAKGQE7N3DPLQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-lf0-f72.google.com ([209.85.215.72])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCXY5TXHWYJRBWNIR3LAKGQE7N3DPLQ@isocpp.org>)
	id 1f3ND1-0001Cr-52
	for gclcip-std-proposals@m.gmane.org; Tue, 03 Apr 2018 16:46:51 +0200
Original-Received: by mail-lf0-f72.google.com with SMTP id f135-v6sf4451161lfg.18
        for <gclcip-std-proposals@m.gmane.org>; Tue, 03 Apr 2018 07:48:59 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1522766939; cv=pass;
        d=google.com; s=arc-20160816;
        b=BrSGCWpI7mMUnk/a423+CGj5ZPQY4rc9Tr2FpDxVYoODsXMxbOMRBF0Hya9gmTwL11
         pzYT1j0Hu70OOJuDRs/ncP2C/31+U6oH5veLTpgMC9QGfoiZFt6V5SuFPI/SMimLDkF0
         LeovbkPm/pJHmQHCcCaWOWVkThj+kP5zJoMDuo0QflAUfjKFK6h/GflYCC3+p+l+hLOw
         UF8M3vTs2HD7rwqku8zg9sVBbzB2/jWiXBI55nNEw2pEvv7NfGtND4E0aTxtTS+vGRpD
         Qr0VJXwLUy3RwR8aVWvJjGiN55GcuwyYEdwmbmvVJU1OTO9Q88EidIYol1xIO45Oelf9
         gcZQ==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
         :list-id:mailing-list:precedence:reply-to:content-language
         :in-reply-to:mime-version:user-agent:date:message-id:from:references
         :to:subject:arc-authentication-results:arc-message-signature
         :dkim-signature:arc-authentication-results;
        bh=V/3jCMeb6NXAJprHEHtIDWRKwEq4bZChKmdauXchnp8=;
        b=b/S2L8+de1icrTQKfopYayeArl0sJvRQQ3gPqL41bd9PNnSJZXegIF6afQQEGdg6Cm
         vxnScY3qAxKqMIegkjFmALob1lxfSCP+nKXFjmgUieaNBfoVifNKiRXSKiNp639BYbp+
         F9s5egIA5YCt00yWjQJw2mmkpnlHxU4YOHKDg5dR39+Z5uKyat8oRD147Q8HM9RjTvjj
         SULKzj/8Riy1O0cieBvTIJmaT1Sx1YDLLis0pIUwIIpZ0O7N2ggEhroMmO9XzCgqhOES
         CuLAKpbEGDpWDj67vl9Jw3scehvq/qgfOkLgmvfqegam/6bVDOqpLOHgDwA0e2bfgC9v
         GJnQ==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=bxOixAWT;
       spf=pass (google.com: domain of andrey.semashev@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=andrey.semashev@gmail.com;
       dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=subject:to:references:from:message-id:date:user-agent:mime-version
         :in-reply-to:content-language: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=V/3jCMeb6NXAJprHEHtIDWRKwEq4bZChKmdauXchnp8=;
        b=KciD6DxGUsozAvBHPhNrkS/Qx/u4rZ52I+MENy/49r7261pLWAwmALGsSh7BJfD5X4
         uw9f2LtzwBi4OC9CMsqnG5Oi0uUM2EwoZNKhz4CsFL8gKtWeRhZH6rz8DZSe9GeK0yRv
         HObs1iiHc9n5A+AuhA+vIh/rmd+Pdwep04P85IdJyngUpkktljVE2UTi6yI9iKJoAakv
         aNMs+NmAC6Hax2VULV8P+Pv86ODgs0K4r+FLPfmwOwsd1ekR/YOXHQfULEiztxJJwvLj
         f/eDpPbLRkLxlFsTSNeiscYbLx/n9RBFWsSMKOiK8DdDJybdRWUXT9h9HkZjO3FswObY
         X9zA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:subject:to:references:from:message-id:date
         :user-agent:mime-version:in-reply-to:content-language
         :x-original-sender:x-original-authentication-results:reply-to
         :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post
         :list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=V/3jCMeb6NXAJprHEHtIDWRKwEq4bZChKmdauXchnp8=;
        b=ucy87kpWbC/Y6MnPPPby2sYUm8td29jGkXLafreZkRloVcoNkUTNtV6Ag04x3TF5ZF
         iDNvjjC3moXzZoDO5QlJ0FU8/qxsEAEdmnKpzxTn1S2a7n9S/K5ioED6NnRG8KwLluDt
         J48SJwNXYIPTFcZCkOSfoXwB8/lA3wCzZYIwJFSQStNoUjwJHzetsYRXkUk5uecb8iZA
         f8XPq0N4bMLc3ABENkfF14PGqTPJPi69fyVUH2q0QVUxv89FXeboylz0k9M2luDTV2mS
         84so0eYmo0HT2OH0G3Lb62QhHvLgOkLDRc713PnbQuXLspq2r3T1LIMIi8ZP31IzhHis
         7 
X-Gm-Message-State: AElRT7FmEuRin8gjDXOYAB49UF4F5usS3H9WVIeOES1HnQCHkLQopXs/
	y7Vs0Vjt/u5faBf1cLxakCFY5A==
X-Google-Smtp-Source: AIpwx4/dWw8Ru4DmPERnBt6Vp3HCxZS2UqpcEqD3nWyTZ6UijRxedNht2ixeeiGD8CkFUnrHbr5jAQ==
X-Received: by 10.46.158.81 with SMTP id g17mr575735ljk.14.1522766939145;
        Tue, 03 Apr 2018 07:48:59 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:a19:fc0c:: with SMTP id a12-v6ls48968lfi.13.gmail; Tue, 03
 Apr 2018 07:48:57 -0700 (PDT)
X-Received: by 2002:a19:274b:: with SMTP id n72-v6mr8604840lfn.48.1522766937343;
        Tue, 03 Apr 2018 07:48:57 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1522766937; cv=none;
        d=google.com; s=arc-20160816;
        b=HzQQNnKBoMwDVC66lL//uJzFdsioXAf0A72qCo1WgnBC3zDgnIPr662CUGXIIi2o8R
         Hh2fTzM623JlurVBkobBDwd+R9FZYg+2ZNrhmRfOJry+TWBNwjcJgccm32Xv+8eV1C9Z
         2tS2Jy0IHlHsQkCOyTDnAjAvhaqfxPl6AXF1rkZOmqWYctrY6AhDnLWqmc/MpY2iQrPw
         0fIE5vlBT9hnmWbmhL33NU86P2R0MLcGO7Uvz/sA4p8XWjs/w3xNq3VAHJzK1eNYYXrI
         0xTliE8h/GF1xT2OY8gANIeeXC9GQYB6fy/w0DwgP3Qwj3c3v/zNtwnGXSkn4iElVMd0
         6jlQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=content-transfer-encoding:content-language:in-reply-to:mime-version
         :user-agent:date:message-id:from:references:to:subject
         :dkim-signature:arc-authentication-results;
        bh=XDmuVyIwSXi1VwDOTZdGWrHhQP/o9cn18cryZs01g8o=;
        b=0qg3D1SOSHZssBmADdaTT5KNq7THRouOFX8SQVmNRSJjCiGGJGUUbA4Wja5gLQ9aLH
         5Nn4StAAiMvt6//zNYfzVdDNjH5E//R+FWdsHRMRrK/32DLHAxDBDxcS3u3Ixi9IbQOf
         eavWyOWA6LgKN6Lua7HzRzzs0QximME+6uVVyj24FZ8rIzn4eKaLCc2Pn8i/wam8UmKv
         Bpu05FIgg55fAEHs0/qOTNMm96azERdQErmYisnJT5XcxOT/qb4uG47JGK7X0GfuM/wz
         3JkmINoIt9LnWBve2B8aLec++nz0HnrpFPGoTOW7l+OjC8OumJc0fz0HUWQCItHHrfc+
         gCPg==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=bxOixAWT;
       spf=pass (google.com: domain of andrey.semashev@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=andrey.semashev@gmail.com;
       dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com
Original-Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65])
        by mx.google.com with SMTPS id 141sor528244ljf.77.2018.04.03.07.48.57
        for <std-proposals@isocpp.org>
        (Google Transport Security);
        Tue, 03 Apr 2018 07:48:57 -0700 (PDT)
Received-SPF: pass (google.com: domain of andrey.semashev@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65;
X-Received: by 10.46.156.132 with SMTP id x4mr8791988lji.19.1522766936715;
        Tue, 03 Apr 2018 07:48:56 -0700 (PDT)
Original-Received: from [192.168.1.2] (broadband-109-173-28-102.moscow.rt.ru. [109.173.28.102])
        by smtp.googlemail.com with ESMTPSA id w73-v6sm561805lfi.60.2018.04.03.07.48.55
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Tue, 03 Apr 2018 07:48:56 -0700 (PDT)
In-Reply-To: <CAHSYqdbJzNpUAsH+P1PAPv2UO2v-KEFrecC36rMSwQuvKQHc1w@mail.gmail.com>
Content-Language: en-US
X-Original-Sender: andrey.semashev@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com header.s=20161025 header.b=bxOixAWT;       spf=pass
 (google.com: domain of andrey.semashev@gmail.com designates 209.85.220.65 as
 permitted sender) smtp.mailfrom=andrey.semashev@gmail.com;       dmarc=pass
 (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: std-proposals@isocpp.org
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://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>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:37617
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/37617>

On 04/03/18 16:37, Hyman Rosen wrote:
> On Tue, Apr 3, 2018 at 5:01 AM, Bengt Gustafsson 
> <bengt.gustafsson@beamways.com <mailto:bengt.gustafsson@beamways.com>> 
> wrote:
> 
>     For the particular use of floating point precision control volatile
>     seems very inefficient as you don't really need writing and reading
>     main memory. Maybe an intrinsic std::preserve_precision() would be a
>     good thing to propose?
> 
> On the contrary, if the compiler is going to insist on doing the wrong thing
> on behalf of the optimizationists, volatile gives me just the control I need
> (i.e., on particular results) and does it in a standard-conforming way 
> that's
> already in the language, and in C as well, since the problem exists 
> there also.

AFAICS, C allows to perform operations with increased precision, see C11 
6.3.1.8/2. I do not find a similar grant in C++ though, but I consider 
it a very useful one, which allows things like FMA.

I'm struggling to see a use case where I would want reduced precision of 
math operations where they could potentially be more precise for free. 
Your use of volatile for this purpose is certainly unusual and, I'd 
wager, not the intended use case for it.

-- 
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/ff48755d-ef5a-4f6d-7ac1-a408ac2ddfaa%40gmail.com.

.
