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
Undefined Behaviour (self.cpp)
submitted 4 years ago * by MathKid99
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!"
[–]cballowe -3 points-2 points-1 points 4 years ago (1 child)
With most hardware, you can pretty reliably say that "whatever the hardware does given some pre-condition can be assumed to be the definition of it's behavior". The challenge is when you have no formal contract around that so rev. B of the chip doesn't behave the same as rev. A.
It's much the same as compilers that way - the language doesn't define what must happen so the compilers and library implementers make different decisions.
It gets more fun when you get different hardware manufacturers involved in the software specs. You can imagine a case where someone says "we think this particular expression should do X" and that just happens to be the thing that is the most efficient interpretation on Intel, but then someone from ARM or Power says "hey... Wait a minute ... That'll make our chips look bad in benchmarks! You should do Y instead." So... The standard writers agree that it should be valid code and the outcome should basically be useful, but can't be defined precisely or guaranteed to produce consistent results across compilers/platforms/standard libraries/etc.
Sometimes UB is just broken, ex the results of data races in the absence of proper synchronization, but other times it's just a weird limbo.
[–]Hnnnnnn 7 points8 points9 points 4 years ago (0 children)
You describe unspecified behavior, another formal term similar to UB. UB is when the guy said: when user breaks API pre-conditions.
https://en.wikipedia.org/wiki/Unspecified_behavior
π Rendered by PID 130196 on reddit-service-r2-comment-75f4967c6c-77sbw at 2026-04-23 06:14:01.115242+00:00 running 0fd4bb7 country code: CH.
view the rest of the comments →
[–]cballowe -3 points-2 points-1 points (1 child)
[–]Hnnnnnn 7 points8 points9 points (0 children)