Blog

Tag Archives: undefined-behavior

Customers, customers, customers
Pascal Cuoq on 24 January 2013

The recent posts on extremely minor undefined behaviors in zlib neatly tie in with a discussion on John Regehr's blog about the future-proofitude of C and C++. Another insightful post in this regard is this one by Derek Jones. Derek claims that the situation is different for proprietary compilers with...

Read More

Bad zlib, bad! No compare pointer!
Pascal Cuoq on 16 January 2013

In a previous post we remarked that the decompression function of zlib for some inputs computes an invalid pointer. But at least it neither dereferences it nor compares it to another pointer. Or does it? Recipe for an invalid pointer comparison Instrument Take an ordinary zlib library version 1.2.7 and...

Read More

Compiler-driven language development
Pascal Cuoq on 17 November 2012

A quiz What is pressing “return” next below going to reveal GCC has done wrong? $ cat t.c #include <limits.h> int x = -1; int main(int c, char **v) { x = INT_MIN % x; return x; } ~ $ gcc -std=c99 t.c ~ $ ./a.out Answer: $ ./a.out Floating...

Read More

The previous post was written in jest
Pascal Cuoq on 25 July 2012

Just a quick update to provide context for the previous post. The previous post assumes the reader is familiar with the notion of undefined behavior and how C compilers have started to justify their more aggressive optimizations along the lines of “this program has always been undefined”. Long ago, a...

Read More

On the redundancy of C99's restrict
Pascal Cuoq on 25 July 2012

The restrict keyword in C99 C99 introduced a restrict keyword. The intention is to let the programmer specify the absence of alias between some inputs of a function ey is writing. Consider the function: int f1(int * restrict p int * restrict q) { *p = 1; *q = 2;...

Read More