Tag Archives: undefined-behavior

Reading indeterminate contents might as well be undefined
Pascal Cuoq on 13 March 2013

Warning: on a punctiliousness scale ranging from zero to ten, this post is a good nine-and-a-half. There was no tag for that, so I tagged it both “C99” and “C11”. The faithful reader will know what to expect. There is a bit of C90, too. To summarize, it may appear...

Read More

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