People occasionally ask why LLVM-compiled code sometimes generates SIGTRAP signals when the optimizer is turned on. After digging in, they find that Clang generated a "ud2" instruction (assuming X86 code) - the same as is generated by __builtin_trap().
Years ago I wrote an article about how to do epsilon floating-point comparisons by using integer comparisons. That article has been quite popular (it is frequently cited, and the code samples have …
In this article we examine the strict aliasing rules of the C programming language which are the basis for Type-Based Alias Analysis and show some quirks
Inspiring Lunatics, Tainting Meats
There is always a certain amount of tension between the goals of those using older, less-popula [...]
wingolog: article: on-stack replacement in v8
Writing R Extensions
Writing R Extensions
wingolog: article: static single assignment for functional programmers
The rules of logic no longer apply when you cross the line.
Writing R Extensions
Collection of posts that I found particularly interesting or fun
Suppose you want to write some code to communicate using a binary protocol. You would think C (or C++) was a natural language for this. After all, low level data manipulation is one of it’s s…
To highlight exactly how I think Go could be better, I want to make comparisons to Rust.
I’ve recently been dipping my toes in the very deep water that is “undefined behavior” in C and C++, and the more I learn about it, the scarier it …
Naming is hard. After all, it is one of the two hard problems of computer science, with cache invalidation and off-by-one errors. Mostly we would assume that poorly chosen type and variable names would merely make the code harder to read, but turns out they can lead to undefined behaviour, too. And no, I'm not talking about the reserved identifiers in C (I mean, who would use _Foo or __init__ as identifiers? Nonsense!), but rather something a bit more subtle.
matklad's Arts&Crafts
In this article, you′re going to find 60 terrible coding tips — and explanations of why they are terrible. It′s a fun and serious piece at the same time. No matter how terrible these tips look, they...
Part of the sales pitch for Rust is that it's "as bare metal as C". 1 Rust can do anything C can do, run anywhere C can run, 2 with code...
Exploring Rust's escape hatch for writing low-level code that the powerful type system of Rust cannot guarantee to be safe.