Skip to content

Commit b74546c

Browse files
committed
Warn about or prevent VLA use in C++
ARM and GNU compilers currently are in a mode where they will accept VLAs in C++ as an extension. IAR does not accept them in C++. Avoid potential portability surprises by making GCC warn, and deactivating the extension in ArmCC.
1 parent 80a03e1 commit b74546c

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

tools/toolchains/arm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class ARM(mbedToolchain):
3838
"--brief_diagnostics", "--restrict", "--multibyte_chars", "-I \""+ARM_INC+"\""],
3939
'asm': [],
4040
'c': ["--md", "--no_depend_system_headers", "--c99", "-D__ASSERT_MSG"],
41-
'cxx': ["--cpp", "--no_rtti"],
41+
'cxx': ["--cpp", "--no_rtti", "--no_vla"],
4242
'ld': [],
4343
}
4444

tools/toolchains/gcc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class GCC(mbedToolchain):
3838
],
3939
'asm': ["-x", "assembler-with-cpp"],
4040
'c': ["-std=gnu99"],
41-
'cxx': ["-std=gnu++98", "-fno-rtti"],
41+
'cxx': ["-std=gnu++98", "-fno-rtti", "-Wvla"],
4242
'ld': ["-Wl,--gc-sections", "-Wl,--wrap,main",
4343
"-Wl,--wrap,_malloc_r", "-Wl,--wrap,_free_r", "-Wl,--wrap,_realloc_r"],
4444
}

0 commit comments

Comments
 (0)