Repository: abseil/abseil-cpp

Issue #1413: [Bug]: crc_memcpy_x86_64.cc fails to compile on Visual Studio due to usage of C++20 features.
Created: 2023-03-14T23:51:59Z
Describe the issue
When building abseil as part of protobuf, the following error was encountered when building with Visual Studio:
external\protobuf\third_party\abseil-cpp\absl\crc\internal\crc_memcpy_x86_64.cc(391,11): error C7555: use of designated initializers requires at least '/std:c++20' [build_win32\Debug\protobuf\third_party\abseil-cpp\absl\abseil_dll.vcxproj]

Steps to reproduce the problem
Build abseil as part of protobuf using CMakeLists.txt.
What version of Abseil are you using?
20230125.0
What operating system and version are you using?
Windows Server 1909
What compiler and version are you using?
Visual Studio 16 2019
What build system are you using?
CMake 3.18.3
Additional context
The implementation of crc_memcpy_x86_64.cc contains code such as this:
      return {
          .temporal = new AcceleratedCrcMemcpyEngine<1, 2>(),
          .non_temporal = new CrcNonTemporalMemcpyAVXEngine(),
      };

This form of aggregate initialization was introduced with C++20. While Visual Studio 2019 appears to support this so long as you enable the C++20 standard, judging from the various documentation it appears that Abseil attempts to support C++14 as a minimum standard. Ideally designated initializers would be removed both here and anywhere else used in the codebase to ensure compatibility.

Duplicate issue #1502: [Bug]: Abseil uses C++20 despite set(CMAKE_CXX_STANDARD 17) at top level
Created: 2023-07-31T12:52:35Z
Describe the issue
I am trying to build Tensorflow Lite (https://www.tensorflow.org/lite/guide/build_cmake) which uses the C++17 standard and which relies on Abseil.
But recently I received compile errors because Abseil uses C++20:
C:\Users\bartp\source\TfLite2.13Gpu\tflite_release_x64\abseil-cpp\absl\crc\internal\crc_memcpy_x86_64.cc(391,11): error C7555: use of designated initializers requires at least '/std:c++20' [C:\Users\bartp\source\TfLite2.13Gpu\tflite_release_x64\_deps\abseil-cpp-build\absl\crc\absl_crc32c.vcxproj]
C:\Users\bartp\source\TfLite2.13Gpu\tflite_release_x64\abseil-cpp\absl\crc\internal\crc_memcpy_x86_64.cc(403,11): error C7555: use of designated initializers requires at least '/std:c++20' [C:\Users\bartp\source\TfLite2.13Gpu\tflite_release_x64\_deps\abseil-cpp-build\absl\crc\absl_crc32c.vcxproj]
C:\Users\bartp\source\TfLite2.13Gpu\tflite_release_x64\abseil-cpp\absl\crc\internal\crc_memcpy_x86_64.cc(409,11): error C7555: use of designated initializers requires at least '/std:c++20' [C:\Users\bartp\source\TfLite2.13Gpu\tflite_release_x64\_deps\abseil-cpp-build\absl\crc\absl_crc32c.vcxproj]
C:\Users\bartp\source\TfLite2.13Gpu\tflite_release_x64\abseil-cpp\absl\crc\internal\crc_memcpy_x86_64.cc(413,15): error C7555: use of designated initializers requires at least '/std:c++20' [C:\Users\bartp\source\TfLite2.13Gpu\tflite_release_x64\_deps\abseil-cpp-build\absl\crc\absl_crc32c.vcxproj]


Tensorflow Lite sets set(CMAKE_CXX_STANDARD 17) at its top level (https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/CMakeLists.txt) as specified by https://github.com/abseil/abseil-cpp/blob/master/FAQ.md
"If you are using CMake as the build system, you'll need to add a line like set(CMAKE_CXX_STANDARD 17) to your top level CMakeLists.txt file."
Steps to reproduce the problem
Steps to reproduce the issue (in Command Prompt):
git clone --single-branch --branch r2.13 https://github.com/tensorflow/tensorflow tensorflow_src
mkdir tflite_release_x64
cd tflite_release_x64
cmake -G "Visual Studio 17" -A "x64" -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded" ..\tensorflow_src\tensorflow\lite
cmake --build . -j 32 --config Release

What version of Abseil are you using?
I am no expert at this, but in tflite_release_x64\abseil-cpp\CMakeLists.txt I notice project(absl LANGUAGES CXX VERSION 20230125), so I presume version 2023_01_25.
What operating system and version are you using?
Windows 10 Pro
What compiler and version are you using?
Microsoft Visual Studio 2022 C++ compiler
What build system are you using?
CMake 3.26.4
Additional context
No response

Closing comment (2023-07-31T14:10:46Z): Duplicate of #1413. This is fixed at head.