On Fri, Sep 06, 2013 at 11:46:10AM +0200, Sebastian Geerken wrote:
[...]
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.
There's a memory problem with the sizeof(buf) because it returns the pointer size, not the array length! Please see the attached test case for details. (Compile with: g++ -W -Wall size3.cc -o size3) -- Cheers Jorge.-