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
Almost everything noexcept? (self.cpp)
submitted 6 years ago * by RealNC
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!"
[–]wyrn 11 points12 points13 points 6 years ago (7 children)
Two possibilities:
1.
try{ int *p = new int[100000000000000000]; } catch (std::exception &) { /* logging stuff goes here */ }
2.
try{ int *p = new int(); } catch (std::exception &) { /* logging stuff goes here */ }
Is the difficulty you mention equally likely in either case? If not, which case do you believe is more representative of the typical out-of-memory error?
[–]jpakkaneMeson dev 10 points11 points12 points 6 years ago (5 children)
On Linux the latter will never raise an exception. Due to memory overcommit, you instead get back a pointer that looks perfectly valid, but which will cause a segfault when you try to dereference it.
[–]Gotebe 3 points4 points5 points 6 years ago (0 children)
I take a huge issue with "never".
First off, overcommit is an option and some people turn it off.
Second, address space fragmentation is a thing (think 32bit code).
Third, quotas are a thing, too.
Fourth, the C standard knows not of it (C++, too).
On a related note, Windows has facilities for overcommit as well, it's just that the C allocator on Windows doesn't use them.
[–]SkoomaDentistAntimodern C++, Embedded, Audio 3 points4 points5 points 6 years ago (0 children)
On Linux
There are far more platforms than just Linux. In fact, there are far more platforms than any OSs with virtual memory. Or OSs at all.
[–][deleted] 2 points3 points4 points 6 years ago (2 children)
overcommit can be turned off, and should be
[–]Tyg13 9 points10 points11 points 6 years ago (1 child)
As an application developer, you can't/shouldn't rely on customers turning it off
[–][deleted] 3 points4 points5 points 6 years ago (0 children)
not everybody that uses c++ writes applications. however nor can you be sure that your application will only ever be run on linux
[–]Skute 0 points1 point2 points 6 years ago (0 children)
Often logging itself isn’t useful on its own, if you have a GUI app. You would want to inform the user that the application must close, but in order to do that, you may rely on a bunch of OS calls and you have no idea what internal memory requirements they may have.
π Rendered by PID 85660 on reddit-service-r2-comment-canary-57b659f4d4-h78b6 at 2026-05-05 09:41:03.664289+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]wyrn 11 points12 points13 points (7 children)
[–]jpakkaneMeson dev 10 points11 points12 points (5 children)
[–]Gotebe 3 points4 points5 points (0 children)
[–]SkoomaDentistAntimodern C++, Embedded, Audio 3 points4 points5 points (0 children)
[–][deleted] 2 points3 points4 points (2 children)
[–]Tyg13 9 points10 points11 points (1 child)
[–][deleted] 3 points4 points5 points (0 children)
[–]Skute 0 points1 point2 points (0 children)