4 ms·
The undefined behavior of C and C++ results in remote code execution to a degree completely unmatched by other languages. Examples of dangerous UB in C always
by pcwalton 11y ago
The undefined behavior of C and C++ results in remote code execution to a degree completely unmatched by other languages.
Examples of dangerous UB in C always use deliberately sloppy code for pedagogical reasons. For real-world examples of problems, look at the CVE database.
- mcguire 11y agoHow much of this is due to problems with C or C++, and how much is simply due to a lack of other languages for systems programming? And yes, a major complaint of mine is using C or C++ when you don't absolutely have to.
- pjmlp 11y ago> How much of this is due to problems with C or C++, and how much is simply due to a lack of other languages for systems programming? You mean lack of Algol, Mesa, Modula-2, Modula-3, Ada, Oberon, Oberon-2, Component Pascal, Object Pascal, Delphi, .... ? C became ubiquous when UNIX got adopted as the enterprise OS, slowly replacing the mainframes. Like JavaScript in browsers or Objective-C in iOS, targeting UNIX meant using C, back in the day companies would pay for UNIX SDKs. No sane company would buy another compiler when they already had to pay for a C one, the official language. The other OS vendors started to offer C compilers in their tools to ease the transition between the new UNIX workstations and their other OS. So alternative saner systems programming languages wither way as C grew stronger and now we are with this problem.
- mcguire 11y ago"Lack of other languages" was poorly worded. I'm sorry. What I meant was that, after the spread of Unix and C, C is the most common systems language in production. (Before the spread of C, I believe assembly was the most common systems language(s).) I suspect that any systems language would have a bad reputation if it were used (and over-used) as much as C.
- ufo 11y agoLots of languages around the time C came out had array bounds checks at runtime. C has a hard time doing that because of pointed and arrays being (mostly) interchangeable.
- deleted 11y ago[deleted]