MantisBT - CMake
View Issue Details
0015494CMakeCMakepublic2015-04-03 13:052015-11-02 09:13
B. Scott Michel 
Brad King 
normalminoralways
closedfixed 
Visual Studio 12Win64
CMake 3.2.1 
CMake 3.3CMake 3.3 
0015494: _cmake_feature_test_cxx_generalized_initializers present in MSVC 18.0.31101.1
This feature is available in Visual Studio 12's C++ compiler, version 18.0.31101.0. There are probably more features that this version of the compiler supports; this one just happens to be important to me. Suggest the following:

--- /c/tmp/MSVC-CXX-FeatureTests.cmake.orig.cmake Fri Apr 3 09:52:49 2015
+++ MSVC-CXX-FeatureTests.cmake Fri Apr 3 09:53:22 2015
@@ -8,6 +8,8 @@
 set(_cmake_oldestSupported "_MSC_VER >= 1600")

 set(MSVC_2015 "_MSC_VER >= 1900")
+set(MSVC_2013_v31101 "_MSC_FULL_VER >= 180031101")
+
 set(_cmake_feature_test_cxx_alignas "${MSVC_2015}")
 set(_cmake_feature_test_cxx_alignof "${MSVC_2015}")
 set(_cmake_feature_test_cxx_binary_literals "${MSVC_2015}")
@@ -21,7 +23,7 @@
 # they silently produced bad code, and are now marked as having partial
 # support in previous versions. The footnote says the support will be complete
 # in MSVC 2015, so support the feature for that version, assuming that is true.
-set(_cmake_feature_test_cxx_generalized_initializers "${MSVC_2015}")
+set(_cmake_feature_test_cxx_generalized_initializers "${MSVC_2013_v31101}")
 set(_cmake_feature_test_cxx_nonstatic_member_init "${MSVC_2015}")
 # Microsoft calls this 'rvalue references v3'
 set(_cmake_feature_test_cxx_defaulted_move_initializers "${MSVC_2015}")
No tags attached.
Issue History
2015-04-03 13:05B. Scott MichelNew Issue
2015-04-03 14:02Brad KingNote Added: 0038397
2015-04-03 14:02Brad KingStatusnew => resolved
2015-04-03 14:02Brad KingResolutionopen => no change required
2015-04-03 15:00B. Scott MichelNote Added: 0038398
2015-04-03 15:01B. Scott MichelNote Added: 0038399
2015-04-03 15:02B. Scott MichelNote Added: 0038400
2015-04-03 15:28Brad KingNote Added: 0038401
2015-04-03 15:38Brad KingNote Added: 0038402
2015-04-03 15:38Brad KingAssigned To => Brad King
2015-04-03 15:38Brad KingStatusresolved => assigned
2015-04-03 15:38Brad KingResolutionno change required => open
2015-04-03 15:38Brad KingTarget Version => CMake 3.3
2015-04-03 16:35Brad KingNote Added: 0038403
2015-04-06 10:13Brad KingNote Added: 0038449
2015-04-06 10:13Brad KingStatusassigned => resolved
2015-04-06 10:13Brad KingResolutionopen => fixed
2015-04-06 10:13Brad KingFixed in Version => CMake 3.3
2015-04-06 13:05B. Scott MichelNote Added: 0038454
2015-04-06 13:14Brad KingNote Added: 0038455
2015-11-02 09:13Robert MaynardNote Added: 0039758
2015-11-02 09:13Robert MaynardStatusresolved => closed

Notes
(0038397)
Brad King   
2015-04-03 14:02   
The comment just above the hunk you edited explains that the implementation in pre-2015 versions is incomplete. This is why the feature is not marked for 2013.
(0038398)
B. Scott Michel   
2015-04-03 15:00   
That doesn't help code bases where generalized initializers are present in the code _and_ the MSVC compiler is used.
(0038399)
B. Scott Michel   
2015-04-03 15:01   
So, CMake should just fail in this case?
(0038400)
B. Scott Michel   
2015-04-03 15:02   
But it should succeed for GNU and Clang... (and fail for the VS Community platform)... that doesn't seem quite right.
(0038401)
Brad King   
2015-04-03 15:28   
If you give "cxx_generalized_initializers" to target_compile_features then CMake will report an error if you try to build with a compiler for which CMake is aware of features and for which it knows the feature is not supported. This allows early failure rather than waiting for (possibly confusing) compiler error messages later.

GNU and Clang compilers have supported cxx_generalized_initializers for a while, so the feature check succeeds for them. MSVC does not support cxx_generalized_initializers prior to VS 2015, so code needing them is not portable to that compiler. This is what CMake is trying to say.

See note [1] on this page:

 http://blogs.msdn.com/b/vcblog/archive/2014/11/17/c-11-14-17-features-in-vs-2015-preview.aspx [^]

and more information on this page:

 http://blogs.msdn.com/b/vcblog/archive/2014/08/19/the-future-of-non-static-data-member-initialization.aspx [^]

They explain that VS 2013 claimed to support generalized initializers but it does not actually support it correctly and can silently produce bad code.

We could instead gate this feature on the cl version mentioned in the blog post that makes the bad use cases a hard error so that code can be fixed to avoid such bad cases. Is cl 18.0.31101.1 this version?
(0038402)
Brad King   
2015-04-03 15:38   
Re 0015494:0038401: What we need is the internal cl version number of VS 2013 Update 3. There is also an Update 4 which presumably has a newer number, but we need the number for Update 3.
(0038403)
Brad King   
2015-04-03 16:35   
Re 0015494:0038402: Found it. VS 2013 Update 3 is cl 18.00.30723.
(0038449)
Brad King   
2015-04-06 10:13   
Fixed:

 Features: VS 2013 Update 3 supports initializer lists
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ecb1d5b4 [^]
(0038454)
B. Scott Michel   
2015-04-06 13:05   
Mine reports 18.0.31101.1, but if it works, it works. Thanks.
(0038455)
Brad King   
2015-04-06 13:14   
Re 0015494:0038454: Thanks for reporting back. VS 2013 Update 4 will of course have a newer version number than Update 3, so that is not surprising.
(0039758)
Robert Maynard   
2015-11-02 09:13   
Closing resolved issues that have not been updated in more than 4 months.