[...]
Thinking about it again, variable length arrays are a feature of C, but not of C++, although it seems that most C++ compilers support it. Since this is a nice feature, but standard C++ should be supported, I've thought of testing it by the configure script, and then hide two different implementations behind a macro. See attached patch, which should be applied to the current hg repository.
What do you think? [...]
Third round: I agree with Jorge that this is quite too complex; and profiling shows no performance gain of using the heap over using the stack, so I've replaced it by new and delete. Cris: please test the latest version from hg, it should compile now. I've tried to force g++ to raise an error in this case, by using this example: --- #include <stdlib.h> int main() { int n = rand() % 10 + 1; char c[n]; } --- but both "g++ -std=c++98 test.cc" and "g++ -std=c++11 test.cc" do not complain. Does someone have an idea? ("g++ --version" => "g++ (Debian 4.7.2-5) 4.7.2") Sebastian