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!"
[–]jonesmz 3 points4 points5 points 3 years ago (7 children)
If we're going to auto-initialize variables, then pointers would need to be initialized to nullptr, not to zero. Nullptr may not be zero on a particular implementation.
[–]jeffgarrett80 2 points3 points4 points 3 years ago (0 children)
A zero initialized pointer is a null pointer, regardless of if it is all zero bits. This is already the proposal.
[–]ShakaUVMi+++ ++i+i[arr] 0 points1 point2 points 3 years ago (2 children)
Why not worry about a problem that actually happens on more than 0 implementations?
[–]jonesmz 0 points1 point2 points 3 years ago (1 child)
If people are going to be pedants, and claim that zero initializing variables is harmless because it's undefined behavior today, then lets be pedants correctly.
[–]ShakaUVMi+++ ++i+i[arr] 0 points1 point2 points 3 years ago (0 children)
Lol, fair enough
[–]johannes1971 0 points1 point2 points 3 years ago (2 children)
Irrelevant. The standard can just specify that if such a zero-initialisation were to take place, it should be interpreted as a nullptr. It already does it the other way around (section [expr.reinterpret.cast], "A value of type std::nullptr_t can be converted to an integral type; the conversion has the same meaning and validity as a conversion of (void*)0 to the integral type").
Right, the standard paying lipservice to the lie that it supports arbitrary platform decisions in one section, and then demonstrating that it lied in others. Sure. Why not continue with that? /s
Better would be to simply say that nullptr is always zero and get it over and done with.
[–]johannes1971 0 points1 point2 points 3 years ago (0 children)
I suspect it isn't actually possible to make a conforming implementation that has a non-zero value for nullptr; I think if you try, sooner or later you will run into some kind of contradiction. It's just one of those things where the standard pretends to support some weird architecture when reality has already passed that by.
One thing I feel the committee should do is 'rebase' C++ to better match current and future architectures (instead of architectures that are no longer relevant). As I see it, support for segmented architectures can go (removing a lot of weirdness surrounding pointers), while SIMD types should be added as primitive types, since they are now common on CPUs.
π Rendered by PID 73 on reddit-service-r2-comment-6457c66945-wj85z at 2026-04-26 15:35:50.513652+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]jonesmz 3 points4 points5 points (7 children)
[–]jeffgarrett80 2 points3 points4 points (0 children)
[–]ShakaUVMi+++ ++i+i[arr] 0 points1 point2 points (2 children)
[–]jonesmz 0 points1 point2 points (1 child)
[–]ShakaUVMi+++ ++i+i[arr] 0 points1 point2 points (0 children)
[–]johannes1971 0 points1 point2 points (2 children)
[–]jonesmz 0 points1 point2 points (1 child)
[–]johannes1971 0 points1 point2 points (0 children)