News for hackers. Stuff that matters.
Re:Getting Past C by awinter-py on Tuesday January 03, 2017 @09:24PM (#13315180)
agree -- inability to do variable-sized arrays on the stack is the root of the problem.
Re:Getting Past C by dbaupp on Tuesday January 03, 2017 @09:47PM (#13315274)
I'm not even talking about variably sized arrays, just creating a statically sized one and passing it into functions that take dynamically-sized one. For instance, a read function that fills an existing buffer doesn't care if the buffer is on the heap or on the stack, it only cares that it doesn't overrun the bounds.

alloca-style variable arrays is a whole other can of worms of danger and complexity.

Re:Getting Past C by enriquto on Wednesday January 04, 2017 @03:50AM (#13316717)
What do you mean? Variable-length arrays are OK in C.
Re:Getting Past C by pjmlp on Wednesday January 04, 2017 @07:52AM (#13317815)
Not in C11, they were removed due to security issues and became an optional language feature.
Re:Getting Past C by awinter-py on Wednesday January 04, 2017 @07:48AM (#13317782)
oops -- you're right.

https://gcc.gnu.org/onlinedocs/gcc/Variable-Length.html

Legal in C99, available in C++ on gcc/clang.

Re:Getting Past C by pjmlp on Wednesday January 04, 2017 @07:55AM (#13317830)
Optional in C11, not accepted in ANSI C++17.
Re:Getting Past C by PeCaN on Wednesday January 04, 2017 @01:06AM (#13316026)
This is what I really like about Ada. Variable-sized arrays and structs on the stack is easy, safe, and efficient in Ada.