4 ms·
Something tells me C++ isn't the best thing to implement a compiler with.
by andrewchambers 12y ago
Something tells me C++ isn't the best thing to implement a compiler with.
- Tloewald 12y agoFYI: someone has modded you down because the compiler is crashing when it compiles the C++ code, not because it is written in any particular language.
- andrewchambers 12y agoI'm aware, I care because LLVM is being integrated in web browsers as part of the JIT engine, and clang uses LLVM as its backend. So any segfaults related to LLVM (though not this one in particular) make me worried about browser security.
- darkpore 12y agolol - you're aware that most web browsers are written in C++?
- andrewchambers 12y agoPainfully aware. You do understand what an ever increasing attack surface does?
- millstone 12y agoThis looks to be an assertion failure, i.e. code that was thought to be unreachable is not. So there's no evidence that any of the negatives of C++ (memory safety, etc.) are in play here.
- andrewchambers 12y agoIf that's the case I was being too harsh on clang.
- golemotron 12y agoI modded you up because clang is written in C++ and even if I didn't know this I'd suspect it because segfaults in languages that are not weakly typed (i.e., C and C++) are incredibly rare. There are better languages to write compilers in. OCaml is one.
- nly 12y agoC++ probably isn't 'weakly typed', whatever that means.
- yzzxy 12y agoYou probably aren't "qualified to make that statement", if you don't know what weak typing is and are too lazy to google it.
- nly 12y agohttps://en.wikipedia.org/wiki/Strong_and_weak_typing https://en.wikipedia.org/wiki/Strong_and_weak_typing > In general, these terms do not have a precise definition. Rather, they tend to be used by advocates or critics of a given programming language, as a means of explaining why a given language is better or worse than alternatives.
- mateo411 12y agoC is weakly typed, because you can cast or set any variable to be a void *. Since C is weakly typed, then you can write a C++ program that is also weakly typed.
- timshen 12y agoI'd rather say that C++ "fixes" C's unsafe type system by making some of the castings legal, instead of safer :)
- andrewchambers 12y agoI guess I was being to harsh on the memory issues in C++. In practice it is a non issue, because build scripts can run arbitrary code long before a memory corruption in the system compiler. And if you plan on running the code you just compiled, you must already trust the code. Unless of course its a segfault in LLVM and not just clang. LLVM is used for JIT in web browsers now, not that there are really any suitable replacements for C++ right now.