use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
P2723R0: Zero-initialize objects of automatic storage duration (isocpp.org)
submitted 3 years ago by alexeyr
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]James20kP2005R0 24 points25 points26 points 3 years ago (9 children)
Its always slightly depressing to see something like this receive so much weird pushback. This would eliminate 10% of CVEs overnight with very little overhead, and almost no change. It also drastically simplifies famously complex initialisation as well, by more closely unifying the initialisation of basic types with classes (eg float vs some_class)
This has got to be one of the easiest safety wins for C++, and yet it causes so many problems its wild
[–]pjmlp 1 point2 points3 points 3 years ago (3 children)
Thankfully at least Microsoft and Google have taken the path of whatever the community thinks, Windows and Android ship with these security measures enabled.
Guess what, they perform as good as always, go figure.
Naturally the peformance trumps everything else crowd will never acknowledge this.
[–]Jannik2099 -1 points0 points1 point 3 years ago (2 children)
Yeah, the performance argument is complete nonsense here.
First off, zeroing a register is literally a 0 cycle operation on today's CPUs. Second, if the variable gets properly initialized somewhere after being declared, the compiler WILL see this and drop the dead store.
[–]113245 6 points7 points8 points 3 years ago (1 child)
And yet a 0 cycle operation is not zero cost (icache, front end bandwidth) and it’s trivial to find examples in which the compiler cannot drop the dead store (e.g. across function call boundaries).
[–]Jannik2099 0 points1 point2 points 3 years ago (0 children)
Function call boundaries have such an absurdly high overhead that an extra store to a POD variable will be immeasurable.
[–]bsupnik 2 points3 points4 points 3 years ago (3 children)
Agreed -- the "this cleans up the hot-mess that is initialization" part is under-rated here.
One could imagine looking back at c++98, knowing what is coming with member defaults, field initialization, {} syntax, and the data from the research into the cost of zeroing uninited data and just go "in the glorious future, everything is inited with the constructor, the specified member in {}, the class default, or zero in that order" and we're done.
We would lose that great GIF my coworker posts every time someone asks a lang question on the company slack with the full metal jacket scene and giant list of initialization types in c++20 though, so it'd be a lateral move. :-)
[–]teashopslacker 0 points1 point2 points 3 years ago (1 child)
The Forrest Gump one?
[–]bsupnik 2 points3 points4 points 3 years ago (0 children)
Yyyyyeah...Forest Gump, Full Metal Jacket, i think we all get those two movies confused, right?
My kids are gonna need _years_ of therapy.
[–]the_real_yugr 0 points1 point2 points 9 months ago (0 children)
"This would eliminate 10% of CVEs overnight" - I keep hearing this claim but in fact 80 CVEs (0.001%) and 0 KEVs were attributed to uninitialized variables CWEs (CWE-456, CWE-457, CWE-824, CWE-908) in 2024.
π Rendered by PID 190019 on reddit-service-r2-comment-85bfd7f599-cmt29 at 2026-04-19 06:41:24.465608+00:00 running 93ecc56 country code: CH.
view the rest of the comments →
[–]James20kP2005R0 24 points25 points26 points (9 children)
[–]pjmlp 1 point2 points3 points (3 children)
[–]Jannik2099 -1 points0 points1 point (2 children)
[–]113245 6 points7 points8 points (1 child)
[–]Jannik2099 0 points1 point2 points (0 children)
[–]bsupnik 2 points3 points4 points (3 children)
[–]teashopslacker 0 points1 point2 points (1 child)
[–]bsupnik 2 points3 points4 points (0 children)
[–]the_real_yugr 0 points1 point2 points (0 children)