From cc0489f6b5a396ac0d26e5e73bdeced82805c1a2 Mon Sep 17 00:00:00 2001 From: Simon Richter Date: Thu, 18 Oct 2018 20:24:01 +0200 Subject: [PATCH] Disallow variable length arrays This is a gcc/clang extension, not standard C++ --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 057125e634..b6161167cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -209,6 +209,13 @@ if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) if(COMPILER_SUPPORTS_WSUGGEST_OVERRIDE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsuggest-override") endif() + + CHECK_CXX_COMPILER_FLAG("-Wvla" COMPILER_SUPPORTS_WVLA) + + if(COMPILER_SUPPORTS_WVLA) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=vla") + endif() + endif()