5 ms·
Your definition of what's considered common sense is based on your sole understanding of computers. It's more like your intuition. Just because you don't under
by halayli 5y ago
Your definition of what's considered common sense is based on your sole understanding of computers. It's more like your intuition.
Just because you don't understand something fully doesn't mean it's not common sense.
It's very common that programmers don't bother reading the standard or attempt to understand the concept of an abstract machine.
Programmers that know what they are doing tend not to be surprised by such nuances.
- userbinator 5y agoNo, I've read the standard. The "abstract machine" is, as its name implies, abstract. In reality, there are other concerns that are equally if not more important. That is the problem with compiler writers, ignoring those practical concerns. They prefer to downvote rather than face the reality of going outside their imaginary abstract machine world. "In theory, theory and practice are the same. In practice, they are not."
- josephcsible 5y agoThe C standard can be thought of as a bunch of minimum requirements that program authors and compiler authors have to follow. What you seem to be arguing is for compiler authors to go above and beyond what's required of them, so that you as a program author can get away with doing less than the minimum that's required for you.
- userbinator 5y agoMe and everyone who has been subject to this "abuse" by compiler-writers stuck in their fantasy world.... including Linus Torvalds: https://news.ycombinator.com/item?id=17242103 https://news.ycombinator.com/item?id=17242103
- Gibbon1 5y agoReminds me once saw an comment about optimizing on UB by a compiler maintainer for Microsoft. He pointedly said the gcc maintainers would do better to work on their crummy code generation.
- astrange 5y agoAren't gcc/clang significantly better than MSVC? They're certainly better at safe code with tools like asan, and at least they support C99.
- pjmlp 5y agoNot updated with Visual Studio 2019? C11 and C17 are supported, minus C99 features made optional in C11. ASan is now in the box. And Visual Studio definitly provides a better experience of coupling static analysis with code being written.
- astrange 5y agoI am a bit behind. Sounds like a good update, since before it was effectively just a C++ compiler that implemented parts of C when it was convenient.
- pjmlp 5y agoOn the contrary, first of all there is no rule that requires a C++ compiler to also be a C compiler. Second, Microsoft considered C done on Windows, and green field systems programming should be done in C++, there were a couple of blog posts done about the subject, which apparently hater kept forgeting to read about. So no, it wasn't about when it was convenient, rather to the extent required by ISO C++ compliance. In fact, as per Microsoft Security Center advisory, C# or other managed languages, Rust or C++ with Core Guidelines, should be the main languages to use for new applications. Most likely they ended up backtracking with the goal to drop C support from Visual Studio due to pressure from high profile customers, WSL and FOSS code on Windows, or even the culture change brought by Satya.
- josephcsible 5y ago> On the contrary, first of all there is no rule that requires a C++ compiler to also be a C compiler. This is true, but an OS with no C compiler is horrifically bad. If Microsoft didn't want their C++ compiler to also be a C compiler, then they should have made a separate C compiler, instead of forcing people to rely on something like MinGW.
- UncleMeat 5y agoAre those practical concerns universal and well aligned with the language's design goals?
- overgard 5y agoThis attitude drives me crazy. C was once a simple language, but now the only people that can write it "correctly" are compiler implementers, and if they fuck up your code, it's your fault. You know how Linus will practically murder anyone that breaks user space, even if user space is "wrong"? I wish compiler makers had the same ethos. BTW, go look at how many optimizations are explicitly disabled to compile the kernel without it breaking and then come back to me with how these are a good idea. One of the most critical pieces of software infrastructure in the world looks at how broken compilers are and says yeah, leave that junk out.
- josephcsible 5y agoWhat you want would basically prohibit all optimizations.
- overgard 5y agoYour point is the standard that "optimizations shouldn't fuck up working code" is unreasonable? What point is there to optimizing something thats wrong? So you can break things 10% faster?
- josephcsible 5y ago> Your point is the standard that "optimizations shouldn't fuck up working code" is unreasonable? By "working code", do you mean code that the standard and/or target implementation promise will do what you want, or do you mean code that just happened to do what you want the last time you tested it on your system? If you mean the latter, then yes.
- overgard 5y agoWhat percentage of code do you honestly think has no undefined behavior? (hint: hardly any). Are you fortunate enough to work in one of those code bases? Remember its not up to you to not write UB, its up to everyone that touches the code base. If you are stuck with UB, would you prefer a compiler that does the safe thing, or a compiler that unleashes dragons?