From 0f4003b7d4f4540b9b6974fc8bb4862aa2066a20 Mon Sep 17 00:00:00 2001
From: Kubat <mael.martin31@gmail.com>
Date: Fri, 20 Aug 2021 20:24:25 +0200
Subject: [PATCH] BUILD: Get ride of vla extension

---
 CMakeLists.txt                                          | 1 -
 src/Lib/Script/CRTPLuaScriptObject.hh                   | 3 ++-
 src/Lib/Script/CRTPLuaScriptObject/ModuleDeclaration.cc | 6 ++----
 3 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7c21382b..deade37d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -133,7 +133,6 @@ if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
         -Wno-padded
         -Wno-global-constructors
         -Wno-exit-time-destructors
-        -Wno-vla-extension
     )
     target_link_libraries(Vivy PRIVATE
         -fopenmp
diff --git a/src/Lib/Script/CRTPLuaScriptObject.hh b/src/Lib/Script/CRTPLuaScriptObject.hh
index f94d27d7..8e9920da 100644
--- a/src/Lib/Script/CRTPLuaScriptObject.hh
+++ b/src/Lib/Script/CRTPLuaScriptObject.hh
@@ -48,7 +48,8 @@ getJobIteratorTypeFromString(const std::string_view it) noexcept
 // CRTP to expose objects to Lua
 template <class Object> class CRTPLuaScriptObject {
 protected:
-    static void __attribute__((__noreturn__)) luaGlobalError(lua_State *const L, const std::string &str) noexcept
+    static void __attribute__((__noreturn__))
+    luaGlobalError(lua_State *const L, const std::string &str) noexcept
     {
         const auto *const context = LuaContext::getContext(L);
         lua_pushfstring(L, "%s:0:%s", context->getCurrentLuaFile().c_str(), str.c_str());
diff --git a/src/Lib/Script/CRTPLuaScriptObject/ModuleDeclaration.cc b/src/Lib/Script/CRTPLuaScriptObject/ModuleDeclaration.cc
index 551a9126..d30eeee2 100644
--- a/src/Lib/Script/CRTPLuaScriptObject/ModuleDeclaration.cc
+++ b/src/Lib/Script/CRTPLuaScriptObject/ModuleDeclaration.cc
@@ -99,10 +99,8 @@ ModuleDeclaration::exportJob(lua_State *const L, const int tableIndex, const std
     JobDeclaration *const job       = context->getJob(moduleName, name);
 
     if (jobItType != JobIteratorType::Line && jobItType != JobIteratorType::Syllabe) {
-        char str[itTypeStr.length() + 1];
-        std::memset(str, 0, sizeof(str));
-        std::strncpy(str, itTypeStr.data(), sizeof(str));
-        luaL_error(L, "The iteration type must be LINE or SYLLABE, got %s", str);
+        const std::string str(itTypeStr);
+        luaL_error(L, "The iteration type must be LINE or SYLLABE, got %s", str.c_str());
     }
 
     else {
-- 
GitLab