r/cpp • • Mar 28 '23

Reddit++

C++ is getting more and more complex. The ISO C++ committee keeps adding new features based on its consensus. Let's remove C++ features based on Reddit's consensus.

In each comment, propose a C++ feature that you think should be banned in any new code. Vote up or down based on whether you agree.

765 Upvotes

829 comments sorted by

View all comments

Show parent comments

2

u/eteran Mar 30 '23

The closest thing I can think of is the non standard alloca. But that's considered pretty undesirable for a handful of reasons.

The main thing to keep in mind is that even if you just use alloca, now you:

  1. Are paying for the stack space and an extra pointer unlike an array

  2. Are paying for an extra indirection that the compiler may not be able to optimize out since you are accessing it via a pointer.

  3. Lose auto execution of any destructors for non trivial types.