220 10096 <CAB+4KHLAd0hrNRThwB-6xPormF1irev8tMKa1V=5RAGR=4uHxg@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: Andrew Tomazos <andrewtomazos@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Shouldn't the constexpr variables be treated as
 static by default?
Date: Sun, 30 Mar 2014 23:02:28 +0200
Lines: 148
Approved: news@gmane.org
Message-ID: <CAB+4KHLAd0hrNRThwB-6xPormF1irev8tMKa1V=5RAGR=4uHxg@mail.gmail.com>
References: <21e34045-b833-4468-a39e-dbf177938012@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=047d7bf0c106a5ef8504f5d94076
X-Trace: ger.gmane.org 1396213355 30010 80.91.229.3 (30 Mar 2014 21:02:35 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Sun, 30 Mar 2014 21:02:35 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBD5KHQXXWYPRBZEM4KMQKGQEPCT5SGI@isocpp.org Sun Mar 30 23:02:30 2014
Return-path: <std-proposals+bncBD5KHQXXWYPRBZEM4KMQKGQEPCT5SGI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-bk0-f70.google.com ([209.85.214.70])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBD5KHQXXWYPRBZEM4KMQKGQEPCT5SGI@isocpp.org>)
	id 1WUMs9-00005N-Q4
	for gclcip-std-proposals@m.gmane.org; Sun, 30 Mar 2014 23:02:29 +0200
Original-Received: by mail-bk0-f70.google.com with SMTP id my13sf15399556bkb.9
        for <gclcip-std-proposals@m.gmane.org>; Sun, 30 Mar 2014 14:02:29 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:mime-version:in-reply-to:references:date
         :message-id:subject:from:to:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe:content-type;
        bh=zPC9OL4SeHx46miLYYEKLeG67AJoUnvWse38PgzsGRM=;
        b=Z78+b/06AOzP2UvhEkMJrzOadOBGrpzdb/9uCwaDCTk0u7md0xHjwktAaZG2WMHxSk
         2bvgQtHhCFs9abRN6WGj1uWBBIHJ0Ph0ROdQ4jbYmolsKnrNCR/dUWZaKEczSSAu0aUz
         OmMBh2HR4D9BBAu2TYgH1+1fl8Fy2B26u/0QmQkGNNcF9yMj8CJV8EmFUhlqJvrKx7gN
         9GmY+GTX4sBLrgNuI7Tfh8NMLr6XOPoTbncAFOTVAlRb0XsmEgN3blBg23pTJYgneweF
         oyFf4PyhToW5xRiYPJhEZzHRBfCjLrmZG+YuJ3XqCTo+i/U6AB0eB4B5H71Ts03KALKJ
         mXIg==
X-Gm-Message-State: ALoCoQnQ7xVGdKY2SkPkOxsTNP0sL6O/lzYX3GT7YIngnvV28tsy3CRri9QZi6cGmEGQWxmOhNfZ
X-Received: by 10.180.198.133 with SMTP id jc5mr4797295wic.4.1396213349363;
        Sun, 30 Mar 2014 14:02:29 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.180.212.4 with SMTP id ng4ls349077wic.45.gmail; Sun, 30 Mar
 2014 14:02:28 -0700 (PDT)
X-Received: by 10.180.126.38 with SMTP id mv6mr7458778wib.46.1396213348430;
        Sun, 30 Mar 2014 14:02:28 -0700 (PDT)
Original-Received: from mail-we0-x232.google.com (mail-we0-x232.google.com [2a00:1450:400c:c03::232])
        by mx.google.com with ESMTPS id jt9si2315944wjc.180.2014.03.30.14.02.28
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Sun, 30 Mar 2014 14:02:28 -0700 (PDT)
Received-SPF: pass (google.com: domain of andrewtomazos@gmail.com designates 2a00:1450:400c:c03::232 as permitted sender) client-ip=2a00:1450:400c:c03::232;
Original-Received: by mail-we0-f178.google.com with SMTP id u56so4047908wes.9
        for <std-proposals@isocpp.org>; Sun, 30 Mar 2014 14:02:28 -0700 (PDT)
X-Received: by 10.194.82.35 with SMTP id f3mr9323955wjy.36.1396213348165; Sun,
 30 Mar 2014 14:02:28 -0700 (PDT)
Original-Received: by 10.227.147.134 with HTTP; Sun, 30 Mar 2014 14:02:28 -0700 (PDT)
In-Reply-To: <21e34045-b833-4468-a39e-dbf177938012@isocpp.org>
X-Original-Sender: andrewtomazos@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of andrewtomazos@gmail.com designates 2a00:1450:400c:c03::232 as
 permitted sender) smtp.mail=andrewtomazos@gmail.com;       dkim=pass
 header.i=@gmail.com;       dmarc=pass (p=NONE 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-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: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:10096
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/10096>

--047d7bf0c106a5ef8504f5d94076
Content-Type: text/plain; charset=ISO-8859-1

This would be a breaking change:

#include <cstdio>

void f(int y)
{
        if (y == 0)
                return;

        constexpr int x = 3;
        const int* p = &x;

        std::printf("%p\n", p);

        f(y-1);
}

int main()
{
        f(3);
}

prints:

0x7fff125fdad8
0x7fff125fdaa8
0x7fff125fda78

whereas with static constexpr it prints:

0x400714
0x400714
0x400714





On Sun, Mar 30, 2014 at 10:55 PM, Mikhail Semenov <
mikhailsemenov1957@gmail.com> wrote:

> There is a recommendation to define all *constexpr* variables as static.
> Shouldn't they be defined like that by default, meaning wherever we write
>
> *constexpr double x = 5.1;*
>
> the variable x will be assumed  always to have  *static storage duration*?
>
>
>
>
>
>
>
>  --
>
> ---
> 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/.
>

-- 

--- 
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/.

--047d7bf0c106a5ef8504f5d94076
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">This would be a breaking change:<div><br></div><div><div>#=
include &lt;cstdio&gt;</div><div><br></div><div>void f(int y)</div><div>{</=
div><div>=A0 =A0 =A0 =A0 if (y =3D=3D 0)</div><div>=A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 return;</div><div><br>
</div><div>=A0 =A0 =A0 =A0 constexpr int x =3D 3;</div><div>=A0 =A0 =A0 =A0=
 const int* p =3D &amp;x;</div><div><br></div><div>=A0 =A0 =A0 =A0 std::pri=
ntf(&quot;%p\n&quot;, p);</div><div><br></div><div>=A0 =A0 =A0 =A0 f(y-1);<=
/div><div>}</div><div><br></div>
<div>int main()</div><div>{</div><div>=A0 =A0 =A0 =A0 f(3);</div><div>}</di=
v><div><br></div></div><div>prints:</div><div><br></div><div><div>0x7fff125=
fdad8</div><div>0x7fff125fdaa8</div><div>0x7fff125fda78</div></div><div><br=
></div>
<div>whereas with static constexpr it prints:</div><div><br></div><div><div=
>0x400714</div><div>0x400714</div><div>0x400714</div></div><div><br></div><=
div><br></div><div><br></div></div><div class=3D"gmail_extra"><br><br><div =
class=3D"gmail_quote">
On Sun, Mar 30, 2014 at 10:55 PM, Mikhail Semenov <span dir=3D"ltr">&lt;<a =
href=3D"mailto:mikhailsemenov1957@gmail.com" target=3D"_blank">mikhailsemen=
ov1957@gmail.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote"=
 style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir=3D"ltr"><div>There is a recommendation to define all <strong>const=
expr</strong> variables as static. </div><div>Shouldn&#39;t they be defined=
 like that by default, meaning wherever we write</div><div><strong><br></st=
rong></div>
<div><strong>constexpr double x =3D 5.1;</strong> </div><div><br></div><div=
>the variable x will be assumed=A0 always to have =A0<strong>static storage=
 duration</strong>?</div><span class=3D"HOEnZb"><font color=3D"#888888"><di=
v><br>
</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br>=
</div><div><br></div></font></span></div><span class=3D"HOEnZb"><font color=
=3D"#888888">

<p></p>

-- <br>
<br>
--- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</font></span></blockquote></div><br></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--047d7bf0c106a5ef8504f5d94076--

.
