enabling constexpr with Visual studio 2015 Update 3 (RC)
I am trying to use the enhanced constexpr features and have (perhaps unwisely) downloaded the latest Visual Studio Update 3 (RC) to get as great a chance of achieving this as possible. https://blogs.msdn.microsoft.com/vcblog/2015/12/02/constexpr-in-vs2015-updat... (and later posts) I am unsure what I need to do to ensure that the compiler is enabled for use the latest features. I have added /std:c++14 to the options of the property for the project. (aside I also tried /std:C++latest but that works for some tasks but failed to compile with odd-looking errors in converter.hpp Error C2518 keyword 'typename' illegal in base class list; ignored \modular-boost\boost\numeric\conversion\detail\converter.hpp 453 // Trivial Converter : used when (cv-unqualified) T == (cv-unqualified) S // template<class Traits> struct trivial_converter_impl : public std::unary_function< BOOST_DEDUCED_TYPENAME Traits::argument_type ,BOOST_DEDUCED_TYPENAME Traits::result_type > ,public dummy_range_checker<Traits> {...} So I stopped trying that /std:c++latest option. What else should it do?) Running the modular-boost/libs/config/config_info.cpp program BOOST_NO_CXX14_CONSTEXPR [no value] BOOST_CONSTEXPR [no value] BOOST_CONSTEXPR_OR_CONST =const BOOST_STATIC_CONSTEXPR =static const These don't seem to be what I think that I would expect (constexpr and static constexpr). I want especially to use BOOST_STATIC_CONSTEXPR to get static constexpr. Do I need to also add #define BOOST_CXX14_CONSTEXPR in my program or elsewhere? (Doing this doesn't change BOOST_CONSTEXPR_OR_CONST from const to constexpr) Thanks for any suggestions. Paul --- Paul A. Bristow Prizet Farmhouse Kendal UK LA8 8AB +44 (0) 1539 561830
pabristow wrote
(aside I also tried /std:C++latest but that works for some tasks but failed to compile with odd-looking errors in converter.hpp
Error C2518 keyword 'typename' illegal in base class list; ignored \modular-boost\boost\numeric\conversion\detail\converter.hpp 453
// Trivial Converter : used when (cv-unqualified) T == (cv-unqualified) S // template <class Traits> struct trivial_converter_impl : public std::unary_function< BOOST_DEDUCED_TYPENAME Traits::argument_type
,BOOST_DEDUCED_TYPENAME Traits::result_type > ,public dummy_range_checker <Traits> {...}
So I stopped trying that /std:c++latest option. What else should it do?)
To use /std:C++latest, you have to add _HAS_AUTO_PTR_ETC=1 to the preprocessor definitions. Otherwise, there is no std::unary_function. -- View this message in context: http://boost.2283326.n4.nabble.com/enabling-constexpr-with-Visual-studio-201... Sent from the Boost - Dev mailing list archive at Nabble.com.
-----Original Message----- From: Boost [mailto:boost-bounces@lists.boost.org] On Behalf Of Marcel Raad Sent: 11 June 2016 16:27 To: boost@lists.boost.org Subject: Re: [boost] enabling constexpr with Visual studio 2015 Update 3 (RC)
pabristow wrote
(aside I also tried /std:C++latest but that works for some tasks but failed to compile with odd-looking errors in converter.hpp
Error C2518 keyword 'typename' illegal in base class list; ignored \modular-boost\boost\numeric\conversion\detail\converter.hpp 453
// Trivial Converter : used when (cv-unqualified) T == (cv-unqualified) S // template <class Traits> struct trivial_converter_impl : public std::unary_function< BOOST_DEDUCED_TYPENAME Traits::argument_type
,BOOST_DEDUCED_TYPENAME Traits::result_type > ,public dummy_range_checker <Traits> {...}
So I stopped trying that /std:c++latest option. What else should it do?)
To use /std:C++latest, you have to add _HAS_AUTO_PTR_ETC=1 to the preprocessor definitions. Otherwise, there is no std::unary_function.
#define _HAS_AUTO_PTR_ETC 1 // http://lists.boost.org/boost-users/2015/09/84966.php seems to get rid of my compile failure. Thanks Paul
-- View this message in context: http://boost.2283326.n4.nabble.com/enabling-constexpr-with-Visual-studio-201... RC-tp4686973p4686975.html Sent from the Boost - Dev mailing list archive at Nabble.com.
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
On Sat, Jun 11, 2016 at 11:41 AM, Paul A. Bristow wrote:
Do I need to also add #define BOOST_CXX14_CONSTEXPR in my program or elsewhere? (Doing this doesn't change BOOST_CONSTEXPR_OR_CONST from const to constexpr)
In develop, you have the option of defining BOOST_MSVC_CXX11_CONSTEXPR. Glen
On Sat, Jun 11, 2016 at 11:57 AM, Glen Fernandes
On Sat, Jun 11, 2016 at 11:41 AM, Paul A. Bristow wrote:
Do I need to also add #define BOOST_CXX14_CONSTEXPR in my program or elsewhere? (Doing this doesn't change BOOST_CONSTEXPR_OR_CONST from const to constexpr)
In develop, you have the option of defining BOOST_MSVC_CXX11_CONSTEXPR.
+1. You might want to read the thread "[config] Changes needed for VC++ 2015 Update 3?" if you have not already done so. Please file a MSVC bug report if you hit any C++11 constexpr bugs in the Update 3 RC. They giving very high priority to C++11 bugs affecting Boost code. They would like us to be able to turn BOOST_NO_CXX11_CONSTEXPR off for Update 3. --Beman
-----Original Message----- From: Boost [mailto:boost-bounces@lists.boost.org] On Behalf Of Beman Dawes Sent: 11 June 2016 17:06 To: Boost Developers List Subject: Re: [boost] enabling constexpr with Visual studio 2015 Update 3 (RC)
On Sat, Jun 11, 2016 at 11:57 AM, Glen Fernandes
wrote: On Sat, Jun 11, 2016 at 11:41 AM, Paul A. Bristow wrote:
Do I need to also add #define BOOST_CXX14_CONSTEXPR in my program or elsewhere? (Doing this doesn't change BOOST_CONSTEXPR_OR_CONST from const to constexpr)
In develop, you have the option of defining BOOST_MSVC_CXX11_CONSTEXPR.
+1.
You might want to read the thread "[config] Changes needed for VC++ 2015 Update 3?" if you have not already done so.
Please file a MSVC bug report if you hit any C++11 constexpr bugs in the Update 3 RC. They giving very high priority to C++11 bugs affecting Boost code. They would like us to be able to turn BOOST_NO_CXX11_CONSTEXPR off for Update 3.
I'm using a just-fully-updated modular-boost develop branch.
I've re-read
https://groups.google.com/forum/#!topic/boost-developers-archive/yzERahUyJRE
and added either or both
#define BOOST_CXX14_CONSTEXPR
#define BOOST_MSVC_CXX14_CONSTEXPR
but when I hover over
BOOST_CONSTEXPR_OR_CONST
it still shows const rather than constexpr
and I am not getting an (unsuccessful so far) attempt to implement constexpr
1>fixed_point_constexpr.cpp(61): error C2127: 'bn1': illegal initialization of 'constexpr' entity with a non-constant expression
that would be shown if I was misunderstanding the meaning of the hover display.
So I'm doing something wrong still.
(In case it helps, the code only contains
#include
-----Original Message----- From: Boost [mailto:boost-bounces@lists.boost.org] On Behalf Of Paul A. Bristow Sent: 13 June 2016 14:55 To: boost@lists.boost.org Subject: Re: [boost] enabling constexpr with Visual studio 2015 Update 3 (RC)
-----Original Message----- From: Boost [mailto:boost-bounces@lists.boost.org] On Behalf Of Beman Dawes Sent: 11 June 2016 17:06 To: Boost Developers List Subject: Re: [boost] enabling constexpr with Visual studio 2015 Update 3 (RC)
On Sat, Jun 11, 2016 at 11:57 AM, Glen Fernandes
wrote: On Sat, Jun 11, 2016 at 11:41 AM, Paul A. Bristow wrote: In develop, you have the option of defining BOOST_MSVC_CXX11_CONSTEXPR.
+1.
You might want to read the thread "[config] Changes needed for VC++ 2015 Update 3?" if you have not already done so.
https://groups.google.com/forum/#!topic/boost-developers-archive/yzERahUyJRE
Please file a MSVC bug report if you hit any C++11 constexpr bugs in the Update 3 RC. They giving very high priority to C++11 bugs affecting Boost code. They would like us to be able to turn BOOST_NO_CXX11_CONSTEXPR off for Update 3.
I've re-re-read the above and realized that I had assumed (the mother of all snafus) C++14 not C++11
BOOST_MSVC_CXX14_CONSTEXPR which has no effect, but BOOST_MSVC_CXX11_CONSTEXPR works as expected (though the compiler is little help in telling just where the constexpr chain is broken :-). But IMO *we really must know* which of std:c++14 and std::c++lastest (and others including c++11, c++17) are being specified for the compiler to use. The compiler version _MSC_FULL_VER = 190024123 does not tell you this - only that it is VS 2015 update 3. I agree that this is a showstopper for Boost. Has this message got back to Microsoft? Paul --- Paul A. Bristow Prizet Farmhouse Kendal UK LA8 8AB +44 (0) 1539 561830
pabristow wrote
But IMO *we really must know* which of std:c++14 and std::c++lastest (and others including c++11, c++17) are being specified for the compiler to use.
The compiler version _MSC_FULL_VER = 190024123 does not tell you this - only that it is VS 2015 update 3.
Seems like _MSVC_LANG is 201403 and _HAS_CXX17 is 1 with /std:c++latest. _MSVC_LANG is 201402 and _HAS_CXX17 is 0 with /std:c++14. See yvals.h. -- View this message in context: http://boost.2283326.n4.nabble.com/enabling-constexpr-with-Visual-studio-201... Sent from the Boost - Dev mailing list archive at Nabble.com.
-----Original Message----- From: Boost [mailto:boost-bounces@lists.boost.org] On Behalf Of Marcel Raad Sent: 16 June 2016 07:50 To: boost@lists.boost.org Subject: Re: [boost] enabling constexpr with Visual studio 2015 Update 3 (RC)
pabristow wrote
But IMO *we really must know* which of std:c++14 and std::c++lastest (and others including c++11, c++17) are being specified for the compiler to use.
The compiler version _MSC_FULL_VER = 190024123 does not tell you this - only that it is VS 2015 update 3.
Seems like _MSVC_LANG is 201403 and _HAS_CXX17 is 1 with /std:c++latest. _MSVC_LANG is 201402 and _HAS_CXX17 is 0 with /std:c++14. See yvals.h.
Confirmed thanks. /std:c++latest Hello Boost! Platform: Win32 Compiler: Microsoft Visual C++ version 14.0 STL : Dinkumware standard library version 650 Boost : 1.61.0 _MSC_VER =1900 _MSC_FULL_VER=190024123 _MSVC_LANG=201403L __cplusplus=199711L _HAS_CXX17=1 _HAS_AUTO_PTR_ETC=0 Processor architecture = (x64) /std:c++14 Hello Boost! Platform: Win32 Compiler: Microsoft Visual C++ version 14.0 STL : Dinkumware standard library version 650 Boost : 1.61.0 _MSC_VER =1900 _MSC_FULL_VER=190024123 _MSVC_LANG=201402L __cplusplus=199711L _HAS_CXX17=0 _HAS_AUTO_PTR_ETC=1 Processor architecture = (x64) but confusingly, _MSVC_LANG is not shown as defined using the IDE, but only gets defined and a value assigned when called by, for example, PRINT_MACRO in boost_1_61_0_b1\libs\config\test\config_info.cpp These macro MSVC_LANG and _HAS_CXX17 could usefully be added to config_info.cpp? This looks workable, if not uber convenient or clear. But things are getting better - slowly... Paul --- Paul A. Bristow Prizet Farmhouse Kendal UK LA8 8AB +44 (0) 1539 561830
_MSVC_LANG is the macro to hook on. Hopefully, there will be a published
documentation of how to test for _MSC_VER and _MSVC_LANG. The actual value
of _MSVC_LANG may change, but the landmark values to check against are
those defined by the C++ standards for __cplusplus. So you would be testing
_MSVC_LANG > 201402L
for post-C++14 features.
On Thu, Jun 16, 2016 at 3:16 AM, Paul A. Bristow
-----Original Message----- From: Boost [mailto:boost-bounces@lists.boost.org] On Behalf Of Marcel Raad Sent: 16 June 2016 07:50 To: boost@lists.boost.org Subject: Re: [boost] enabling constexpr with Visual studio 2015 Update 3 (RC)
pabristow wrote
But IMO *we really must know* which of std:c++14 and std::c++lastest (and others including c++11, c++17) are being specified for the compiler to use.
The compiler version _MSC_FULL_VER = 190024123 does not tell you this - only that it is VS 2015 update 3.
Seems like _MSVC_LANG is 201403 and _HAS_CXX17 is 1 with /std:c++latest. _MSVC_LANG is 201402 and _HAS_CXX17 is 0 with /std:c++14. See yvals.h.
Confirmed thanks.
/std:c++latest Hello Boost! Platform: Win32 Compiler: Microsoft Visual C++ version 14.0 STL : Dinkumware standard library version 650 Boost : 1.61.0 _MSC_VER =1900 _MSC_FULL_VER=190024123 _MSVC_LANG=201403L __cplusplus=199711L _HAS_CXX17=1 _HAS_AUTO_PTR_ETC=0 Processor architecture = (x64)
/std:c++14 Hello Boost! Platform: Win32 Compiler: Microsoft Visual C++ version 14.0 STL : Dinkumware standard library version 650 Boost : 1.61.0 _MSC_VER =1900 _MSC_FULL_VER=190024123 _MSVC_LANG=201402L __cplusplus=199711L _HAS_CXX17=0 _HAS_AUTO_PTR_ETC=1 Processor architecture = (x64)
but confusingly, _MSVC_LANG is not shown as defined using the IDE, but only gets defined and a value assigned when called by, for example, PRINT_MACRO in
boost_1_61_0_b1\libs\config\test\config_info.cpp
These macro MSVC_LANG and _HAS_CXX17 could usefully be added to config_info.cpp?
This looks workable, if not uber convenient or clear. But things are getting better - slowly...
Paul
--- Paul A. Bristow Prizet Farmhouse Kendal UK LA8 8AB +44 (0) 1539 561830
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Note that _HAS_CXX17 will be the STL's documented macro for detecting and controlling the library side of C++17 features. We determine its default value from _MSVC_LANG (for C1XX), but we permit it to be overridden in one direction. Namely, you can request C++17 compiler features, but only C++14 library features.
(At the moment, it is technically possible to request the opposite - C++14 compiler with C++17 library - but that will NOT be supported, as we may need to have new library features take dependencies on new compiler features.)
STL
-----Original Message-----
From: Boost [mailto:boost-bounces@lists.boost.org] On Behalf Of Gabriel Dos Reis
Sent: Sunday, June 19, 2016 7:11 PM
To: boost@lists.boost.org
Subject: Re: [boost] enabling constexpr with Visual studio 2015 Update 3 (RC)
_MSVC_LANG is the macro to hook on. Hopefully, there will be a published documentation of how to test for _MSC_VER and _MSVC_LANG. The actual value of _MSVC_LANG may change, but the landmark values to check against are those defined by the C++ standards for __cplusplus. So you would be testing
_MSVC_LANG > 201402L
for post-C++14 features.
On Thu, Jun 16, 2016 at 3:16 AM, Paul A. Bristow
-----Original Message----- From: Boost [mailto:boost-bounces@lists.boost.org] On Behalf Of Marcel Raad Sent: 16 June 2016 07:50 To: boost@lists.boost.org Subject: Re: [boost] enabling constexpr with Visual studio 2015 Update 3 (RC)
pabristow wrote
But IMO *we really must know* which of std:c++14 and std::c++lastest (and others including c++11, c++17) are being specified for the compiler to use.
The compiler version _MSC_FULL_VER = 190024123 does not tell you this - only that it is VS 2015 update 3.
Seems like _MSVC_LANG is 201403 and _HAS_CXX17 is 1 with /std:c++latest. _MSVC_LANG is 201402 and _HAS_CXX17 is 0 with /std:c++14. See yvals.h.
Confirmed thanks.
/std:c++latest Hello Boost! Platform: Win32 Compiler: Microsoft Visual C++ version 14.0 STL : Dinkumware standard library version 650 Boost : 1.61.0 _MSC_VER =1900 _MSC_FULL_VER=190024123 _MSVC_LANG=201403L __cplusplus=199711L _HAS_CXX17=1 _HAS_AUTO_PTR_ETC=0 Processor architecture = (x64)
/std:c++14 Hello Boost! Platform: Win32 Compiler: Microsoft Visual C++ version 14.0 STL : Dinkumware standard library version 650 Boost : 1.61.0 _MSC_VER =1900 _MSC_FULL_VER=190024123 _MSVC_LANG=201402L __cplusplus=199711L _HAS_CXX17=0 _HAS_AUTO_PTR_ETC=1 Processor architecture = (x64)
but confusingly, _MSVC_LANG is not shown as defined using the IDE, but only gets defined and a value assigned when called by, for example, PRINT_MACRO in
boost_1_61_0_b1\libs\config\test\config_info.cpp
These macro MSVC_LANG and _HAS_CXX17 could usefully be added to config_info.cpp?
This looks workable, if not uber convenient or clear. But things are getting better - slowly...
Paul
--- Paul A. Bristow Prizet Farmhouse Kendal UK LA8 8AB +44 (0) 1539 561830
_______________________________________________ Unsubscribe & other changes: https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2flists. boost.org%2fmailman%2flistinfo.cgi%2fboost&data=01%7c01%7cstl%40exchan ge.microsoft.com%7c7e0f5ee641384abd0e2608d398b953cd%7c72f988bf86f141af 91ab2d7cd011db47%7c1&sdata=cRtaCKPmQcyc6JTxCIfasuWAgMqQU%2bp1Ha82ZkNNh Ac%3d
_______________________________________________ Unsubscribe & other changes: https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2flists.boost.org%2fmailman%2flistinfo.cgi%2fboost&data=01%7c01%7cstl%40exchange.microsoft.com%7c7e0f5ee641384abd0e2608d398b953cd%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=cRtaCKPmQcyc6JTxCIfasuWAgMqQU%2bp1Ha82ZkNNhAc%3d
-----Original Message----- From: Boost [mailto:boost-bounces@lists.boost.org] On Behalf Of Beman Dawes Sent: 11 June 2016 17:06 To: Boost Developers List Subject: Re: [boost] enabling constexpr with Visual studio 2015 Update 3 (RC)
You might want to read the thread "[config] Changes needed for VC++ 2015 Update 3?" if you have not already done so.
Please file a MSVC bug report if you hit any C++11 constexpr bugs in the Update 3 RC. They giving very high priority to C++11 bugs affecting Boost code. They would like us to be able to turn BOOST_NO_CXX11_CONSTEXPR off for Update 3.
Unless I am doing something very silly using Update 3 RC, it is not possible to declare and initialization any constexpr intermediate variables within a constexpr function. constexpr int tripled(int n) { constexpr int f = 3; // C3250: 'f': declaration is not allowed in 'constexpr' function body // constexpr_variable_in_function.cpp(35) : error C3249 : illegal statement or sub - expression for 'constexpr' function return n * f; } even using /std:c++latest Reported as https://connect.microsoft.com/VisualStudio/feedback/details/2849367 My reading of C++17 draft is that is now an added feature, and this work with GCC 5.3.0 (not even the most recent version). Lack of this is a showstopper when trying to define any (mathy) function where it is impossible/impractical to provide a single return statement. Paul --- Paul A. Bristow Prizet Farmhouse Kendal UK LA8 8AB +44 (0) 1539 561830
That is C++14 constexpr; C1XX only supports C++11 constexpr.
Sent from a touchscreen; please excuse the brevity.
On Thu, Jun 23, 2016 at 7:23 AM -0700, "Paul A. Bristow"
-----Original Message----- From: Boost [mailto:boost-bounces@lists.boost.org] On Behalf Of Beman Dawes Sent: 11 June 2016 17:06 To: Boost Developers List Subject: Re: [boost] enabling constexpr with Visual studio 2015 Update 3 (RC)
You might want to read the thread "[config] Changes needed for VC++ 2015 Update 3?" if you have not already done so.
Please file a MSVC bug report if you hit any C++11 constexpr bugs in the Update 3 RC. They giving very high priority to C++11 bugs affecting Boost code. They would like us to be able to turn BOOST_NO_CXX11_CONSTEXPR off for Update 3.
Unless I am doing something very silly using Update 3 RC, it is not possible to declare and initialization any constexpr intermediate variables within a constexpr function. constexpr int tripled(int n) { constexpr int f = 3; // C3250: 'f': declaration is not allowed in 'constexpr' function body // constexpr_variable_in_function.cpp(35) : error C3249 : illegal statement or sub - expression for 'constexpr' function return n * f; } even using /std:c++latest Reported as https://na01.safelinks.protection.outlook.com/?url=https%3a%2f%2fconnect.microsoft.com%2fVisualStudio%2ffeedback%2fdetails%2f2849367&data=01%7c01%7cbion%40microsoft.com%7cff91fe2ba4ea4628db3908d39b71f2e8%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=s%2fuVgTFXoqGoAfgDEOSv%2bgo5ZkyDQ%2b03m8B6of9icHw%3d My reading of C++17 draft is that is now an added feature, and this work with GCC 5.3.0 (not even the most recent version). Lack of this is a showstopper when trying to define any (mathy) function where it is impossible/impractical to provide a single return statement. Paul --- Paul A. Bristow Prizet Farmhouse Kendal UK LA8 8AB +44 (0) 1539 561830 _______________________________________________ Unsubscribe & other changes: https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2flists.boost.org%2fmailman%2flistinfo.cgi%2fboost&data=01%7c01%7cbion%40microsoft.com%7cff91fe2ba4ea4628db3908d39b71f2e8%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=immCBtMvwc7pb3rBkSnywDK4BntAtJrgyEI0MjjAaHU%3d
-----Original Message----- From: Boost [mailto:boost-bounces@lists.boost.org] On Behalf Of Billy O'Neal (VC LIBS) Sent: 23 June 2016 15:29 To: boost@lists.boost.org; boost@lists.boost.org Subject: Re: [boost] enabling constexpr with Visual studio 2015 Update 3 (RC)
That is C++14 constexpr; C1XX only supports C++11 constexpr.
I think it may even be a C++17 feature and I have tried /std:c++14 and /std:c++latest to try to enable this. http://en.cppreference.com/w/cpp/language/constexpr says the function body must be either deleted or defaulted * or contain any statements except:* an asm declaration. Not this a goto statement. No goto. a statement with a label other than case and default. NO labels. a try-block . No trying. a definition of a variable of non-literal type. Is literal (int, float ...) a definition of a variable of static or thread storage duration. No static. a definition of a variable for which no initialization is performed. (variable IS initialized) But maybe the language lawyers can advise if I am mistaken. either way, it's a showstopper for taking existing code and making constexpr functions. But there are more hurdles: template<typename FloatingPointType> ... BOOST_CONSTEXPR_OR_CONST bool is_neg = (f < FloatingPointType(0)); and // Extract the mantissa and exponent. int exp2 = 0; // Initialize to make constexpr possible. BOOST_CONSTEXPR_OR_CONST FloatingPointType fp(frexp((!is_neg) ? f : -f, &exp2)); both fail to compile on VS 2015 update 3 RC and GCC 5.8.0. So there are hoops that look out of reach for now. Paul
On Thu, Jun 23, 2016 at 7:23 AM -0700, "Paul A. Bristow"
mailto:pbristow@hetp.u-net.com> wrote: -----Original Message----- From: Boost [mailto:boost-bounces@lists.boost.org] On Behalf Of Beman Dawes Sent: 11 June 2016 17:06 To: Boost Developers List Subject: Re: [boost] enabling constexpr with Visual studio 2015 Update 3 (RC)
You might want to read the thread "[config] Changes needed for VC++ 2015 Update 3?" if you have not already done so.
Please file a MSVC bug report if you hit any C++11 constexpr bugs in the Update 3 RC. They giving very high priority to C++11 bugs affecting Boost code. They would like us to be able to turn BOOST_NO_CXX11_CONSTEXPR off for Update 3.
Unless I am doing something very silly using VS 2015 Update 3 RC, it is not possible to declare and initialization any constexpr intermediate variables within a constexpr function.
constexpr int tripled(int n) { constexpr int f = 3; // C3250: 'f': declaration is not allowed in 'constexpr' function body // constexpr_variable_in_function.cpp(35) : error C3249 : illegal statement or sub - expression for 'constexpr' function
return n * f; } even using /std:c++latest
Reported as
https://na01.safelinks.protection.outlook.com/?url=https%3a%2f%2fconnect.mic... 2fdetails%2f2849367&data=01%7c01%7cbion%40microsoft.com%7cff91fe2ba4ea4628db3908d39b71f2e8%7c72f988bf86f1 41af91ab2d7cd011db47%7c1&sdata=s%2fuVgTFXoqGoAfgDEOSv%2bgo5ZkyDQ%2b03m8B6of9icHw%3d
My reading of C++17 draft is that is now an added feature, and this work with GCC 5.3.0 (not even the most recent version).
Lack of this is a showstopper when trying to define any (mathy) function where it is impossible/impractical to provide a single return statement.
Paul
--- Paul A. Bristow Prizet Farmhouse Kendal UK LA8 8AB +44 (0) 1539 561830
_______________________________________________ Unsubscribe & other changes: https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2flists.boost.org%2fmailman%2flistinfo.cgi%2fboost&dat a=01%7c01%7cbion%40microsoft.com%7cff91fe2ba4ea4628db3908d39b71f2e8%7c72f988bf86f141af91ab2d7cd011db47% 7c1&sdata=immCBtMvwc7pb3rBkSnywDK4BntAtJrgyEI0MjjAaHU%3d
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
I think it may even be a C++17 feature and I have tried /std:c++14 and /std:c++latest to try to enable this.
Extended constexpr was a C++14 feature. /std:c++14 and /std:c++latest don't turn this on because C1XX does not have support for it. We implement only C++11 constexpr at this time, which means constexpr functions must be of the form "return expression;".
Billy3
________________________________
From: Boost
-----Original Message----- From: Boost [mailto:boost-bounces@lists.boost.org] On Behalf Of Billy O'Neal (VC LIBS) Sent: 23 June 2016 15:29 To: boost@lists.boost.org; boost@lists.boost.org Subject: Re: [boost] enabling constexpr with Visual studio 2015 Update 3 (RC)
That is C++14 constexpr; C1XX only supports C++11 constexpr.
I think it may even be a C++17 feature and I have tried /std:c++14 and /std:c++latest to try to enable this. https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2fen.cppreference.com%2fw%2fcpp%2flanguage%2fconstexpr&data=01%7c01%7cbion%40microsoft.com%7ca35d14a8cc9b416013fd08d39b7d9c7d%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=z1Qv6kRkG8d7dCFKX4Q8DwB2a4wI3S6w9pftYjeDZdI%3d says the function body must be either deleted or defaulted * or contain any statements except:* an asm declaration. Not this a goto statement. No goto. a statement with a label other than case and default. NO labels. a try-block . No trying. a definition of a variable of non-literal type. Is literal (int, float ...) a definition of a variable of static or thread storage duration. No static. a definition of a variable for which no initialization is performed. (variable IS initialized) But maybe the language lawyers can advise if I am mistaken. either way, it's a showstopper for taking existing code and making constexpr functions. But there are more hurdles: template<typename FloatingPointType> ... BOOST_CONSTEXPR_OR_CONST bool is_neg = (f < FloatingPointType(0)); and // Extract the mantissa and exponent. int exp2 = 0; // Initialize to make constexpr possible. BOOST_CONSTEXPR_OR_CONST FloatingPointType fp(frexp((!is_neg) ? f : -f, &exp2)); both fail to compile on VS 2015 update 3 RC and GCC 5.8.0. So there are hoops that look out of reach for now. Paul
On Thu, Jun 23, 2016 at 7:23 AM -0700, "Paul A. Bristow"
mailto:pbristow@hetp.u-net.com> wrote: -----Original Message----- From: Boost [mailto:boost-bounces@lists.boost.org] On Behalf Of Beman Dawes Sent: 11 June 2016 17:06 To: Boost Developers List Subject: Re: [boost] enabling constexpr with Visual studio 2015 Update 3 (RC)
You might want to read the thread "[config] Changes needed for VC++ 2015 Update 3?" if you have not already done so.
Please file a MSVC bug report if you hit any C++11 constexpr bugs in the Update 3 RC. They giving very high priority to C++11 bugs affecting Boost code. They would like us to be able to turn BOOST_NO_CXX11_CONSTEXPR off for Update 3.
Unless I am doing something very silly using VS 2015 Update 3 RC, it is not possible to declare and initialization any constexpr intermediate variables within a constexpr function.
constexpr int tripled(int n) { constexpr int f = 3; // C3250: 'f': declaration is not allowed in 'constexpr' function body // constexpr_variable_in_function.cpp(35) : error C3249 : illegal statement or sub - expression for 'constexpr' function
return n * f; } even using /std:c++latest
Reported as
https://na01.safelinks.protection.outlook.com/?url=https%3a%2f%2fconnect.mic... 2fdetails%2f2849367&data=01%7c01%7cbion%40microsoft.com%7cff91fe2ba4ea4628db3908d39b71f2e8%7c72f988bf86f1 41af91ab2d7cd011db47%7c1&sdata=s%2fuVgTFXoqGoAfgDEOSv%2bgo5ZkyDQ%2b03m8B6of9icHw%3d
My reading of C++17 draft is that is now an added feature, and this work with GCC 5.3.0 (not even the most recent version).
Lack of this is a showstopper when trying to define any (mathy) function where it is impossible/impractical to provide a single return statement.
Paul
--- Paul A. Bristow Prizet Farmhouse Kendal UK LA8 8AB +44 (0) 1539 561830
_______________________________________________ Unsubscribe & other changes: https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2flists.boost.org%2fmailman%2flistinfo.cgi%2fboost&dat a=01%7c01%7cbion%40microsoft.com%7cff91fe2ba4ea4628db3908d39b71f2e8%7c72f988bf86f141af91ab2d7cd011db47% 7c1&sdata=immCBtMvwc7pb3rBkSnywDK4BntAtJrgyEI0MjjAaHU%3d
_______________________________________________ Unsubscribe & other changes: https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2flists.boost.org%2fmailman%2flistinfo.cgi%2fboost&data=01%7c01%7cbion%40microsoft.com%7ca35d14a8cc9b416013fd08d39b7d9c7d%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=BCapNXGMBjAshlWPQhNBG%2bRh9nZ7y0sZarQrrLI7nHo%3d
_______________________________________________ Unsubscribe & other changes: https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2flists.boost.org%2fmailman%2flistinfo.cgi%2fboost&data=01%7c01%7cbion%40microsoft.com%7ca35d14a8cc9b416013fd08d39b7d9c7d%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=BCapNXGMBjAshlWPQhNBG%2bRh9nZ7y0sZarQrrLI7nHo%3d
On 23 Jun 2016 at 17:56, Billy O'Neal (VC LIBS) wrote:
Extended constexpr was a C++14 feature. /std:c++14 and /std:c++latest don't turn this on because C1XX does not have support for it. We implement only C++11 constexpr at this time, which means constexpr functions must be of the form "return expression;".
I believe typedef/using expressions are permitted before the return statement. You can also, of course, throw exceptions instead of returning in C++ 11. BTW been making heavy use of variable templates in Update 2, apart from all the ICEs it's a great clutter remover. Niall -- ned Productions Limited Consulting http://www.nedproductions.biz/ http://ie.linkedin.com/in/nialldouglas/
-----Original Message----- From: Boost [mailto:boost-bounces@lists.boost.org] On Behalf Of Billy O'Neal (VC LIBS) Sent: 23 June 2016 18:57 To: boost@lists.boost.org Subject: Re: [boost] enabling constexpr with Visual studio 2015 Update 3 (RC)
I think it may even be a C++17 feature and I have tried /std:c++14 and /std:c++latest to try to enable this.
Extended constexpr was a C++14 feature. /std:c++14 and /std:c++latest don't turn this on because C1XX does not have support for it. We implement only C++11 constexpr at this time, which means constexpr functions must be of the form "return expression;".
:-( (especially when /std:c++14 or /std:c++latest imply this should be supported). I look forward to update 4 (or 5...) ;-) Paul ________________________________
From: Boost
on behalf of Paul A. Bristow Sent: Thursday, June 23, 2016 8:46:30 AM To: boost@lists.boost.org Subject: Re: [boost] enabling constexpr with Visual studio 2015 Update 3 (RC) -----Original Message----- From: Boost [mailto:boost-bounces@lists.boost.org] On Behalf Of Billy O'Neal (VC LIBS) Sent: 23 June 2016 15:29 To: boost@lists.boost.org; boost@lists.boost.org Subject: Re: [boost] enabling constexpr with Visual studio 2015 Update 3 (RC)
That is C++14 constexpr; C1XX only supports C++11 constexpr.
I think it may even be a C++17 feature and I have tried /std:c++14 and /std:c++latest to try to enable this.
https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2fen.cpprefere... stexpr&data=01%7c01%7cbion%40microsoft.com%7ca35d14a8cc9b416013fd08d39b7d9c7d%7c72f988bf86f141af91ab2d7c d011db47%7c1&sdata=z1Qv6kRkG8d7dCFKX4Q8DwB2a4wI3S6w9pftYjeDZdI%3d says
the function body must be either deleted or defaulted
* or contain any statements except:*
an asm declaration. Not this a goto statement. No goto. a statement with a label other than case and default. NO labels. a try-block . No trying. a definition of a variable of non-literal type. Is literal (int, float ...) a definition of a variable of static or thread storage duration. No static. a definition of a variable for which no initialization is performed. (variable IS initialized)
But maybe the language lawyers can advise if I am mistaken.
either way, it's a showstopper for taking existing code and making constexpr functions.
But there are more hurdles: template<typename FloatingPointType> ... BOOST_CONSTEXPR_OR_CONST bool is_neg = (f < FloatingPointType(0));
and
// Extract the mantissa and exponent. int exp2 = 0; // Initialize to make constexpr possible. BOOST_CONSTEXPR_OR_CONST FloatingPointType fp(frexp((!is_neg) ? f : -f, &exp2));
both fail to compile on VS 2015 update 3 RC and GCC 5.8.0.
So there are hoops that look out of reach for now.
Paul
On Thu, Jun 23, 2016 at 7:23 AM -0700, "Paul A. Bristow"
> wrote: -----Original Message----- From: Boost [mailto:boost-bounces@lists.boost.org] On Behalf Of Beman Dawes Sent: 11 June 2016 17:06 To: Boost Developers List Subject: Re: [boost] enabling constexpr with Visual studio 2015 Update 3 (RC)
You might want to read the thread "[config] Changes needed for VC++ 2015 Update 3?" if you have not already done so.
Please file a MSVC bug report if you hit any C++11 constexpr bugs in the Update 3 RC. They giving very high priority to C++11 bugs affecting Boost code. They would like us to be able to turn BOOST_NO_CXX11_CONSTEXPR off for Update 3.
Unless I am doing something very silly using VS 2015 Update 3 RC, it is not possible to declare and initialization any constexpr intermediate variables within a constexpr function.
constexpr int tripled(int n) { constexpr int f = 3; // C3250: 'f': declaration is not allowed in 'constexpr' function body // constexpr_variable_in_function.cpp(35) : error C3249 : illegal statement or sub - expression for 'constexpr' function
return n * f; } even using /std:c++latest
Reported as
https://na01.safelinks.protection.outlook.com/?url=https%3a%2f%2fconnect.mic...
2fdetails%2f2849367&data=01%7c01%7cbion%40microsoft.com%7cff91fe2ba4ea4628db3908d39b71f2e8%7c72f988bf86f1
41af91ab2d7cd011db47%7c1&sdata=s%2fuVgTFXoqGoAfgDEOSv%2bgo5ZkyDQ%2b03m8B6of9icHw%3d
My reading of C++17 draft is that is now an added feature, and this work with GCC 5.3.0 (not even the most recent version).
Lack of this is a showstopper when trying to define any (mathy) function where it is impossible/impractical to provide a single return statement.
Paul
--- Paul A. Bristow Prizet Farmhouse Kendal UK LA8 8AB +44 (0) 1539 561830
_______________________________________________ Unsubscribe & other changes:
a=01%7c01%7cbion%40microsoft.com%7cff91fe2ba4ea4628db3908d39b71f2e8%7c72f988bf86f141af91ab2d7cd011db47%
7c1&sdata=immCBtMvwc7pb3rBkSnywDK4BntAtJrgyEI0MjjAaHU%3d
_______________________________________________ Unsubscribe & other changes: https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2flists.boost.org%2fmailman%2flistinfo.cgi%2fboost&dat a=01%7c01%7cbion%40microsoft.com%7ca35d14a8cc9b416013fd08d39b7d9c7d%7c72f988bf86f141af91ab2d7cd011db47 %7c1&sdata=BCapNXGMBjAshlWPQhNBG%2bRh9nZ7y0sZarQrrLI7nHo%3d
_______________________________________________ Unsubscribe & other changes: https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2flists.boost.org%2fmailman%2flistinfo.cgi%2fboost&dat a=01%7c01%7cbion%40microsoft.com%7ca35d14a8cc9b416013fd08d39b7d9c7d%7c72f988bf86f141af91ab2d7cd011db47 %7c1&sdata=BCapNXGMBjAshlWPQhNBG%2bRh9nZ7y0sZarQrrLI7nHo%3d
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
participants (8)
-
Beman Dawes
-
Billy O'Neal (VC LIBS)
-
Gabriel Dos Reis
-
Glen Fernandes
-
Marcel Raad
-
Niall Douglas
-
Paul A. Bristow
-
Stephan T. Lavavej