Something tells me C++ isn't the best thing to implement a compiler with.
There are better languages to write compilers in. OCaml is one.
21–30 of 40 posts
Something tells me C++ isn't the best thing to implement a compiler with.
There are better languages to write compilers in. OCaml is one.
While we're at segfaulting compiler's, here's what I found just a few days ago: python -S -c 'print("void f(){} int main(){return (" + "*"*10**7 + "f)();}")' | gcc -xc - (This is legal C -- look it up. Don't argue with me over the practical relevance of this please)
Sure it's legal, but the bug you are demonstrating is uninteresting. It may not even technically be a violation of the C standard
Earlier quoted context omitted.
Yeah, maybe this is just a standard-conforming implementation of undefined behavior.
It's nothing to do with standard-conforming or not. A correct implementation shall never crash.
"Correctness" itself isn't an absolute. While something either does or does not conform to whatever has been defined as "correct", it's perfectly fine for the defined "correct" behavior in a given situation to be a crash.
In some cases a crash is the best that can be hoped for. Continuing on, even in an attempt to handle the failure more gracefully, can potentially be more harmful than just crashing.
Something tells me C++ isn't the best thing to implement a compiler with.
I 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.
Earlier quoted context omitted.
I 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.
C++ probably isn't 'weakly typed', whatever that means.
While we're at segfaulting compiler's, here's what I found just a few days ago: python -S -c 'print("void f(){} int main(){return (" + "*"*10**7 + "f)();}")' | gcc -xc - (This is legal C -- look it up. Don't argue with me over the practical relevance of this please)
python -c 'print ("int main(){" + "*" * (10**6) + "}")' | gcc -x c -Earlier quoted context omitted.
It's nothing to do with standard-conforming or not. A correct implementation shall never crash.
That's a pretty broad and idealistic claim to be making. "Correctness" itself isn't an absolute. While something either does or does not conform to whatever has been defined as "correct", it's perfectly fine for the defined "correct" behavior in a given situation to be a crash. In some cases a crash is the best that can be hoped for. Continuing on, even in an attempt to handle the failure more gracefully, can potenti…
Something tells me C++ isn't the best thing to implement a compiler with.
I 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.
Something tells me C++ isn't the best thing to implement a compiler with.
This 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.
While we're at segfaulting compiler's, here's what I found just a few days ago: python -S -c 'print("void f(){} int main(){return (" + "*"*10**7 + "f)();}")' | gcc -xc - (This is legal C -- look it up. Don't argue with me over the practical relevance of this please)
I don't expect a compiler to be able to compile programs that exceed its internal limits, but a better error message would be much appreciated, instead of a hard crash. For comparison, with MSVC the parent's code produces
fatal error C1026: parser stack overflow, program too complex
and the nested parentheses results in fatal error C1013: compiler limit : too many open parentheses