simd-everywhere / simde

Implementations of SIMD instruction sets for systems which don't natively support them.
https://simd-everywhere.github.io/blog/
MIT License
2.35k stars 243 forks source link

simde-common.h:414:12: error: use of 'auto' in lambda parameter declaration only available with '-std=c++14' or '-std=gnu++14' #80

Closed mr-c closed 4 years ago

mr-c commented 4 years ago

https://gist.github.com/mr-c/334ce2011b6add547948a4fdc11478fa

http://last.cbrc.jp/last-1047.zip + https://salsa.debian.org/med-team/last-align/blob/master/debian/patches/simde + https://github.com/nemequ/simde

mr-c commented 4 years ago

Bumping https://github.com/nemequ/simde/blob/master/simde/simde-common.h#L412 from __cplusplus >= 201103L to __cplusplus >= 201402L gets us

../debian/include/simde/x86/avx.h: In function 'simde__m128d simde_mm_cmp_pd(simde__m128d, simde__m128d, int)':
../debian/include/simde/x86/../simde-common.h:427:10: error: void value not ignored as it ought to be
  427 |        }))
nemequ commented 4 years ago

Oops. Sorry, I know better than to do that in C++11 (or at least I should)...

3f8932ab74b41fc1b2e7cbc3075451f9e81935e0 should fix it. I'll push it to master as soon as CI finishes.

mr-c commented 4 years ago

:-D No worries, thanks!

Shall we add a -std=c++{11,14,20} axis to the tests?

nemequ commented 4 years ago

Nah, I don't think it's necessary. Since the project is really written in C we don't have much stuff that changes between C++ versions, I don't think it's worth the resources on Travis.

We could have different configurations we already test also test different versions of C++, though For example, c++14 on clang-9, 11 on gcc-8 x86, 98 on gcc 7, etc.

nemequ commented 4 years ago

Another option I was playing around with last night is randomizing the C/C++ versions on CI:

diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 9f4752f..6cbbe68 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -7,6 +7,20 @@ include (ExtraWarningFlags)

 enable_testing()

+function(random_item OUTVAR)
+  string(RANDOM LENGTH 5 ALPHABET 0123456789 random_str)
+  math(EXPR idx "(${random_str} % (${ARGC} - 1)) + 1")
+  list(GET ARGV ${idx} result)
+  set(${OUTVAR} "${result}" PARENT_SCOPE)
+endfunction(random_item)
+
+if(CXX_STANDARD STREQUAL "random")
+  random_item(CXX_STANDARD 98 11 14)
+endif()
+if(C_STANDARD STREQUAL "random")
+  random_item(C_STANDARD 99 11 17)
+endif()
+
 option(BUILD_CPP_TESTS "Build C++ tests" OFF)

 if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/munit/munit.c")
@@ -129,7 +143,12 @@ foreach(native native emul)
   add_library(simde-test-${native} STATIC ${TEST_SOURCES_C} ${TEST_SOURCES_CPP})

   target_include_directories(simde-test-${native} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/..")
-  set_property(TARGET simde-test-${native} PROPERTY C_STANDARD "99")
+  if(C_STANDARD)
+    set_property(TARGET simde-test-${native} PROPERTY C_STANDARD "${C_STANDARD}")
+  endif()
+  if(CXX_STANDARD)
+    set_property(TARGET simde-test-${native} PROPERTY CXX_STANDARD "${CXX_STANDARD}")
+  endif()

   target_link_libraries(run-tests simde-test-${native})
 endforeach(native native emul)

So if you pass -D{C,CXX}_STANDARD=random to CMake it will randomly choose a standard from C99+/C++98+. There are some obvious drawbacks so I haven't made a decision, but instead of restricting the testing to a specific compiler we could check all compilers.