Re:My C code works with -O3 but not with -O0
by gnulinux on Thursday January 16, 2020 @12:11PM
(#22066513)
That's not my point, I don't contest that safe languages are safer. I contest the idea that we should "just use" something else. All my tools are written in C, the entire GNU toolchain is in C, how am I supposed to operate in this world if I "just don't use" C?
Re:My C code works with -O3 but not with -O0
by benibela on Thursday January 16, 2020 @05:54PM
(#22069949)
That is the disadvantage of open-source, it forces you to use the language of someone else's source.
I used Delphi on Windows. Most of the code I wrote in the last 20 years is in Pascal.
And that works really well on Windows. You have a stable API, and it does not matter what language the API is written in. Any language can use the API in the same way.
I tried to run some old projects this month. My 20 year old Delphi Windows programs run better in WINE on Linux than most programs I wrote 5 years using Linux tools, because the libraries have changed, but the API has not
Re:My C code works with -O3 but not with -O0
by apta on Thursday January 16, 2020 @01:13PM
(#22067204)
I think OP was implying not to write new code in C. If possible, we can also use replacement tools written in safer languages if they offer the functionality we need (e.g. `ripgrep` instead of `grep`, or web servers written in safe languages over those written in C/C++).
Re:My C code works with -O3 but not with -O0
by boomer_joe on Thursday January 16, 2020 @01:36PM
(#22067434)
ripgrep isn't POSIX compliant. It's hardly a proper replacement.
Re:My C code works with -O3 but not with -O0
by burntsushi on Thursday January 16, 2020 @04:06PM
(#22068922)
Right, it is intentionally not POSIX compliant. This saves fairly significant development effort and also permits expanding the tool to be more user friendly, such as transparently searching UTF-16 encoded files.
ripgrep cannot be a drop-in replacement. Despite that, it can certainly replace grep in a wide variety of use cases. See: https://github.com/BurntSushi/ripgrep/blob/master/FAQ.md#pos...
It's pretty much established that even expert C and C++ programmers, especially for larger code bases, will end up making some sort of mistake that will cause a security vulnerability or undefined behavior.