by pjmlp · 4y ago · 0 comments
Additionally Google spent several years paying to clean up the Linux kernel from all VLA occurrences.
Sadly, the C committee doesn't really understand what was wrong with VLAs and a sizable group of its members wants to make them mandatory again:
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2921.pdf ("Does WG14 want to make VLAs fully mandatory in C23")
exhibit A: https://lists.freedesktop.org/archives/mesa-commit/2020-Dece...
exhibit B: https://github.com/neovim/neovim/issues/5229
exhibit C: https://github.com/sailfishos-mirror/llvm-project/commit/6be...
etc etc
#include <cstdlib>
#include <span>
__attribute__((annotate("realtime")))
void process_floats(std::span<float> vec)
{
auto filter = (float*) malloc(sizeof(float) * vec.size());
/* fill filter with values */
for(int i = 0; i < vec.size(); i++)
vec[i] *= filter[i];
free(filter);
}
$ stoat-compile++ -c foo.cpp -emit-llvm -std=c++20
$ stoat foo.bc
Parsing 'foo.bc'...
Error #1:
process_floats(std::span<float, 18446744073709551615ul>) _Z14process_floatsSt4spanIfLm18446744073709551615EE
##The Deduction Chain:
##The Contradiction Reasons:
- malloc : NonRealtime (Blacklist)
- free : NonRealtime (Blacklist)
oh noes :((What does 'mandatory' mean? Like if I write a C compiler without them... what are they going to do about it?