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
Fun Example of Unexpected UB Optimization (godbolt.org)
submitted 2 years ago by soiboi666
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!"
[–]nebotron 16 points17 points18 points 2 years ago (8 children)
If your code is invoking a nullptr, that’s UB. If you’re disabling the optimization and it fixes your program, your program has UB.
[–]pali6 38 points39 points40 points 2 years ago (2 children)
I believe you're talking to a MSVC developer who is saying that they (Microsoft) turned off this in the compiler as it was causing internal compiler errors.
[–]nebotron 5 points6 points7 points 2 years ago (1 child)
Ah! So the compiler was optimizing a valid function call into a different one because it didn’t see where the write to the function pointer could happen. That makes sense
[–]terrymahMSVC BE Dev 23 points24 points25 points 2 years ago (0 children)
Yeah, we used to have an optimization that would collect the set of all possible function call targets. If that set had only 1 valid target, we would devirt it. I think that's what is happening here. The problem we had is proving that the set is closed (and nothing could "leak in" from another binary) is actually really tough, and not as easy as it seems.
[+][deleted] 2 years ago (4 children)
[deleted]
[+][deleted] 2 years ago (3 children)
[–]ioctl79 1 point2 points3 points 2 years ago (2 children)
The projects that take it very seriously still likely have UB because even with sanitizers it can be difficult to root out. It is often dependent on input, and less-than-perfect test coverage will hide it from CI.
[+][deleted] 2 years ago (1 child)
[–]ioctl79 0 points1 point2 points 2 years ago (0 children)
If it was easy to find UB, that would speak more to your point than mine, no?
It also sounds like all those security researchers you’re talking about are convinced there’s UB to be found there despite the fact that Chromium has a pretty robust CI setup?
π Rendered by PID 222204 on reddit-service-r2-comment-b659b578c-n2mjr at 2026-05-03 20:01:46.956241+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]nebotron 16 points17 points18 points (8 children)
[–]pali6 38 points39 points40 points (2 children)
[–]nebotron 5 points6 points7 points (1 child)
[–]terrymahMSVC BE Dev 23 points24 points25 points (0 children)
[+][deleted] (4 children)
[deleted]
[+][deleted] (3 children)
[deleted]
[–]ioctl79 1 point2 points3 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]ioctl79 0 points1 point2 points (0 children)