4 ms·
> You are correct to note that the programming language I'm describing does not perfectly conform to any of the documents that are ever called a "C standard". B
by zodiac 10y ago
> You are correct to note that the programming language I'm describing does not perfectly conform to any of the documents that are ever called a "C standard". But that programming language is central to our computing infrastructure
I don't agree with this. Yes, people often write code that unintentionally rely on UB/implementation-specific behavior; but are there important projects that do this intentionally? In any case, compiler authors are going to follow the C standards, not you hypothetical "C-in-practice" standards, so what good does it do to for formalize or clearly specify the latter?
- naasking 10y ago> I don't agree with this. Yes, people often write code that unintentionally rely on UB/implementation-specific behavior; but are there important projects that do this intentionally? The Linux kernel.
- laughinghan 10y ago> are there important projects that do this intentionally? Expecting integer overflow to be two's complement is so common that successors like Java, Go, and Rust all standardized on it, used by hashing algorithms and more: https://github.com/rust-lang/rfcs/pull/560 https://github.com/rust-lang/rfcs/pull/560 > In any case, compiler authors are going to follow the C standards, not you hypothetical "C-in-practice" standards "The optimizer does go to some effort to "do the right thing" when it is obvious what the programmer meant (such as code that does "* (int *)P" when P is a pointer to float)." --blogpost by the second most widely used C compiler, clang/llvm: http://blog.llvm.org/2011/05/what-every-c-programmer-should-know_21.html http://blog.llvm.org/2011/05/what-every-c-programmer-should-...
- greglindahl 10y agoUnsigned integers in C have defined wrap and that is what portable hash functions use.
- deleted 10y ago[deleted]