Top all-time · #1451
Krister Walfridsson
Personal blog · kristerw.blogspot.comprogrammingsystems
Krister Walfridsson's personal blog at kristerw.blogspot.com covers programming and systems. Since 2015, 51 different Hacker News readers have linked it 91 times, most often “Why undefined behavior may call a never-called function”. The last post was in 2021, but the archive is still widely read.
Random thoughts on programming languages, compilers, operating systems, etc.
Most-linked posts?
- Why undefined behavior may call a never-called function14 people · 15 mentions · first linked 2017-09-04
- /2016/02/how-undefined-signed-overflow-enables.html6 people · 6 mentions · first linked 2016-11-28
- Useful GCC warning options not enabled by -Wall -Wextra5 people · 5 mentions · first linked 2017-09-17
- How LLVM Optimizes Geometric Sums4 people · 8 mentions · first linked 2019-04-28
- How LLVM Optimizes Power Sums3 people · 3 mentions · first linked 2022-10-27
- The structure of a GCC back end2 people · 2 mentions · first linked 2017-08-06
- Building GCC 1.272 people · 2 mentions · first linked 2019-01-26
- Building GCC 1.27 (first GCC with x86 support) (2019)2 people · 2 mentions · first linked 2024-04-02
- The cost of conditional moves and branches2 people · 2 mentions · first linked 2017-03-05
- How undefined signed overflow enables optimizations in GCC2 people · 2 mentions · first linked 2016-02-21
What Hacker News says?
> What does that even mean in the absence of a formal standard and competing compiler implementations? (Hint: nothing.) Undefined behaviour is stuff that you compiler's optimizers have been promised can never occur, so they are allowed to transform your code based on that assumption. Here's a post I made on Reddit in 2019 with a list of resources on what undefined behaviour is: https://www.reddit.com/r/rust/comments…
Comment linking /2017/09/why-undefined-behavior-may-call-never.html
on “An RFC that adds support for Rust to the Linux kernel”Submitted Useful GCC warning options not enabled by -Wall -Wextra as a story · 288 points
HN discussion> That could literally produce no output program? Way worse than even that (you might be noticing a theme here...). Once the optimizer has removed as dead code any branch that, if taken, would provably lead to UB at some arbitrary future point of execution, it can conclude that the other branch is now the only possible execution, and call it unconditionally, even if that leads to removing all your files (the classic…
Comment linking /2017/09/why-undefined-behavior-may-call-never.html
on “Rust 1.45”Submitted Why undefined behavior may call a never-called function as a story · 139 points
HN discussion> ANSI Common LISP lives up to that standard. There is only one version of the ANSI Common Lisp standard, so it is trivially compatible with itself. > C's versioning lives up to that standard. Then how do you explain this astonishing work of art? https://kristerw.blogspot.com/2016/07/code-behaving-differen...
Comment linking /2016/07/code-behaving-differently-in-c90-c99.html
on “Rust is mostly safety”Submitted Code behaving differently in C90, C99, C11, C++98, and C++11 as a story · 134 points
HN discussionWhile I like a lot of what's in here, for (size_t i = 9; i <= 9; --i) is a pretty terrible example to put in the second chapter. I would not let that line pass code review. There is no need or place for cutesy cleverness in C. EDIT: Ugh, just found this too: isset[!!largeA[i]] += 1; Not only is that confusingly cutesy, but largeA[i] is a double . Please DON'T write – or encourage beginners to write! – such smug code…
Comment linking /2016/02/how-undefined-signed-overflow-enables.html
on “Modern C [pdf]”Submitted The structure of a GCC back end as a story · 104 points
HN discussionLLVM can do more complex sums, too. See https://kristerw.blogspot.com/2019/04/how-llvm-optimizes-geo...
Comment linking /2019/04/how-llvm-optimizes-geometric-sums.html
on “You can't fool the optimizer”- ot · 2016-02-21
Submitted How undefined signed overflow enables optimizations in GCC as a story · 100 points
HN discussion This explanation of why signed int overflow is undefined is interesting (although the behaviour is still very annoying): https://kristerw.blogspot.com/2016/02/how-undefined-signed-o... (HN discussion: https://news.ycombinator.com/item?id=11146384 ) More examples here: http://blog.llvm.org/2011/05/what-every-c-programmer-should-...
Comment linking /2016/02/how-undefined-signed-overflow-enables.html
on “Making memcpy(NULL, NULL, 0) well-defined”Submitted GCC code generation for C++ Weekly Ep 43 example as a story · 86 points
HN discussionhttps://kristerw.blogspot.com/2016/02/how-undefined-signed-o...
Comment linking /2016/02/how-undefined-signed-overflow-enables.html
on “Rust: Not So Great For Codec Implementing”Submitted Interprocedural optimization in GCC as a story · 84 points
HN discussionTo reinforce this, I still believe C is one of the most elegant syntax's for a "portable assembler". There are many dark corners of C, take for example pointers: https://kristerw.blogspot.com/2016/03/c-pointers-are-not-har...
Comment linking /2016/03/c-pointers-are-not-hardware-pointers.html
on “The Resurgence of C Programming”Submitted Building GCC 1.27 (first GCC with x86 support) (2019) as a story · 76 points
HN discussion> Everyone says that and they have no proof. Here's an entire blog post with proof: https://kristerw.blogspot.com/2016/02/how-undefined-signed-o...
Comment linking /2016/02/how-undefined-signed-overflow-enables.html
on “Nearly all binary searches and mergesorts are broken (2006)”Submitted Type-based aliasing in C as a story · 71 points
HN discussionFor some examples of the types of optimizations enabled by allowing overflow to be undefined: https://kristerw.blogspot.com/2016/02/how-undefined-signed-o...
Comment linking /2016/02/how-undefined-signed-overflow-enables.html
on “Signed Integers Are Two’s Complement”Submitted Watching for software inefficiencies with Valgrind as a story · 67 points
HN discussionThat particular behavior (and some other examples of pathological optimizer behavior) is probably an emergent property of how several optimizations combine as opposed to being a specifically targeted optimization. I can imagine something the optimizer doing something like: 1. Determine possible function call targets 2. Eliminate invalid targets from call set 3. If only one target remains, replace indirect call with…
Comment linking /2017/09/follow-up-on-why-undefined-behavior-may.html
on “One Word Broke C”Submitted Writing a GCC back end as a story · 58 points
HN discussionIt's C++, but UB allows the compiler to call a function the programmer never called https://kristerw.blogspot.com/2017/09/why-undefined-behavior... I'm not sure how any compiler writer can condone this behaviour.
Comment linking /2017/09/why-undefined-behavior-may-call-never.html
on “One Word Broke C”Submitted More Turing-completeness in surprising places as a story · 48 points
HN discussion> Setting aside the question of what exactly "undefined behavior" means, why does a language spec have to include it? If there is behavior that cannot be defined, why not just omit it from the standard? The original reason was that there were things they didn't want to define. For example, signed integer overflow works differently on different hardware architectures. If they defined one behavior in the standard then…
Comment linking /2016/02/how-undefined-signed-overflow-enables.html
on “Security flaws caused by compiler optimizations”Submitted C pointers are not hardware pointers as a story · 45 points
HN discussionNo, it is very generic. See https://kristerw.blogspot.com/2019/04/how-llvm-optimizes-geo... , https://blog.matthieud.me/2020/exploring-clang-llvm-optimiza... (discussed at https://news.ycombinator.com/item?id=28207207 ) (I remember reading a page with more examples, but cannot find it)
Comment linking /2019/04/how-llvm-optimizes-geometric-sums.html
on “In C++, is empty() faster than comparing the size with zero?”Submitted Why volatile is hard to specify and implement as a story · 38 points
HN discussionYeah. Here's a GCC developer experimenting with a 31-year old GCC version on a modern system (the first one with x86 support): >It is amazing how well things work – the modern assembler, linker, and debugger handles the code generated by GCC 1.27 without any problems. https://kristerw.blogspot.com/2019/01/building-gcc-127.html And the write-up he based his experiments upon: https://miyuki.github.io/2017/10/04/gcc-ar…
Comment linking /2019/01/building-gcc-127.html
on “IT professionals should work in a mainframe environment at some point (2015)”Submitted Instruction-less computation as a story · 28 points
HN discussion