GeistHaus
log in · sign up

What Every C Programmer Should Know About Undefined Behavior #1/3

blog.llvm.org

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().

30 pages link to this URL
Tricks With the Floating-Point Format

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 …

0 inbound links article en AltDevBlogADayFloating PointMathProgramming
Type-Based Alias Analysis in C

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

wingolog

wingolog: article: on-stack replacement in v8

1 inbound link en igaliaosrv8javascriptgoopsguilecompilers
wingolog

wingolog: article: static single assignment for functional programmers

2 inbound links en compilersssacpsschemeigaliav8mltonguileanf
Danger, Will Robinson!

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 …

0 inbound links en linux c c++ ub undefined behavior ubsan CC BY-NC-ND 4.0
A curiously recurring lifetime issue

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.

0 inbound links article en
60 terrible tips for a C++ developer

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...

1 inbound link article en C++ CppKnowledge