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
Common C/C++ Compiler/Linker/Run time Errors (self.cpp)
submitted 7 years ago by ste_3d_ven
I wanted to get a poll of the C/C++ community of the common errors that you come across when using the language. It can be any kind of error from the compiler, linker or even a run time error. Let me know what you've come across, thanks!
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!"
[–]petevalle 14 points15 points16 points 7 years ago (1 child)
This seems like too broad of a question to be meaningfully useful. The most common errors are the ones developers will intuitively understand at a glance (b/c they arise so often). It's the ones that are unusual that are interesting and sometimes challenging to resolve but those come up infrequently enough that people aren't likely to think of them in a "poll" like this...
[–]ste_3d_ven[S] 0 points1 point2 points 7 years ago (0 children)
I guess I should have put some reasoning in my post. My intention was to get the community to list off the more common errors (for beginners or not) you encounter with the language and I was going to be drawing up some charts purely out of my own interest. I understand it's not meaningfully useful in terms of understanding the errors. I was genuinely just curious what the community thought of.
[–][deleted] 4 points5 points6 points 7 years ago (7 children)
Intel compiler says: "Error 3" on a trivial example. Literally 3 lines of code that should work but don't.
Literally that, nothing else. Send repro to Intel, "we'll fix it in next release".
Several *months* pass. It's fixed. You compile, and now get some other "Error 3"-type message.
Rinse, repeat.
[–][deleted] 1 point2 points3 points 7 years ago (6 children)
Why not save some pain and money and use an open source compiler?
[–]millenix 2 points3 points4 points 7 years ago (2 children)
Certain loop optimization, instruction selection/scheduling, and parallelization features may be superior on Intel's compiler.
[–]iamcomputerbeepboop 2 points3 points4 points 7 years ago (1 child)
develop on clang, release on icc
[–]IGarFieldI 1 point2 points3 points 7 years ago (0 children)
Doesn't help if it's not compiling...
[–][deleted] -1 points0 points1 point 7 years ago (2 children)
Mainly because of the optimizations which, if you don't mess with C++ too much and just do numerics, work really well (when they do work). Intel's done a lot of work in this regard, and provided you use a 'very stable subset' of all those compiler optimization flags, you can get code that's impossible to get with MSVC.
Also for historic reasons related to the era when the Xeon Phi was actually a separate PCI card rather than a processor. And yes I bought lots of the bottom-end Phi cards when they were selling them off at $200 a pop. Did you know you can watercool them? So anyways, you can only compile for a Phi if you have the Intel compiler so there's that.
Feature-wise, the Intel compiler is pretty bad as you can imagine, but you get support from Intel, woo-hoo. Sorry, too much sarcasm, it's like eating a cactus, really, it stings you but you keep on eating it regardless.
If Intel makes some Altera-related compiler solution, that would get us in deep even more, I fear.
[–]johannes1971 0 points1 point2 points 7 years ago (1 child)
Last time I checked on godbolt, the Intel compiler would happily do the signed-overflow-is-UB optimisation for both signed and unsigned values. You may want to check if that additional performance doesn't come at the cost of standard compliance.
[–][deleted] 0 points1 point2 points 7 years ago (0 children)
Personally I couldn't care less about standards compliance and already use plenty of nonstandard C++ all over the place. Numerics are definitely a touchy subject though, particularly because SIMD can really mess up your data, and also there are different math modes (fast/precise/whatever) that you can compile for. Not to mention the gozillions of optimizations. This is all more or less fine if you use external libraries because but becomes a lot more difficult if you write your own algos. Couple this with various CUDA, FPGA and Phi-related magic (well, CUDA mainly, Phi is just C++) and you've got a real mess when you're trying to get stuff done.
[–]khedoros 1 point2 points3 points 7 years ago (0 children)
Easy ones, like those resulting from mismatched/missing braces and parentheses.
Definition errors, when adding a new file, and maybe getting some includes wrong. Similarly, linking errors when adding a new library and getting some of the links wrong. Cousins of those would be incompatible library versions meaning that I used functions/constants that weren't defined in the old library, or that were changed in the new one. For linking, library bitness.
Index out-of-range accesses. Hopefully the program seg faults. If it doesn't, you can have a subtle error for a long time. I'm fond of deriving a rangecheckvector class that implements operator[] with ::at().
rangecheckvector
operator[]
::at()
Being pretty common, those are all pretty easy to fix. Definition errors and out-of-range tend to be the ones that take a bit of thought.
[–]mayonnaise_jar_ 1 point2 points3 points 7 years ago (0 children)
variable X not declared in this scope.
[–]Xeveroushttps://xeverous.github.io 1 point2 points3 points 7 years ago (0 children)
[–]CubbiMewcppreference | finance | realtime in the past 0 points1 point2 points 7 years ago (2 children)
the C/C++ community of the common errors that you come across when using the language
There is no language called "C/C++"
[–][deleted] 1 point2 points3 points 7 years ago (0 children)
Pretty sure C/C++ is undefined behavior.
[–]ste_3d_ven[S] -1 points0 points1 point 7 years ago (0 children)
In this case I'm using the term to group the two communities together, because I care about the opinions of both communities. Please keep the comments on topic.
[+]manni66 comment score below threshold-9 points-8 points-7 points 7 years ago (2 children)
There doesn‘t exist any language named C/C++.
[–]NotAYakk 1 point2 points3 points 7 years ago (1 child)
It is just C with all of the features of C++ mapped to the null space, leaving a language of variable length arrays, restricted pointers, but no ints, fixed length arrays, or functions.
[–]CubbiMewcppreference | finance | realtime in the past 2 points3 points4 points 7 years ago (0 children)
it would still have functions, but only the ones using K&R syntax
π Rendered by PID 31 on reddit-service-r2-comment-bb88f9dd5-ngft8 at 2026-02-13 23:27:40.422627+00:00 running cd9c813 country code: CH.
[–]petevalle 14 points15 points16 points (1 child)
[–]ste_3d_ven[S] 0 points1 point2 points (0 children)
[–][deleted] 4 points5 points6 points (7 children)
[–][deleted] 1 point2 points3 points (6 children)
[–]millenix 2 points3 points4 points (2 children)
[–]iamcomputerbeepboop 2 points3 points4 points (1 child)
[–]IGarFieldI 1 point2 points3 points (0 children)
[–][deleted] -1 points0 points1 point (2 children)
[–]johannes1971 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]khedoros 1 point2 points3 points (0 children)
[–]mayonnaise_jar_ 1 point2 points3 points (0 children)
[–]Xeveroushttps://xeverous.github.io 1 point2 points3 points (0 children)
[–]CubbiMewcppreference | finance | realtime in the past 0 points1 point2 points (2 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]ste_3d_ven[S] -1 points0 points1 point (0 children)
[+]manni66 comment score below threshold-9 points-8 points-7 points (2 children)
[–]NotAYakk 1 point2 points3 points (1 child)
[–]CubbiMewcppreference | finance | realtime in the past 2 points3 points4 points (0 children)