Blog

Tag Archives: undefined-behavior

Making oughts from ises
Pascal Cuoq on 13 April 2013

A previous post discussed the nature of uninitialized and indeterminate memory throughout the C standards. The argument was “avoid using uninitialized data even if you think you know what you are doing; you may be right but regardless your compiler might think it knows what you are doing and be...

Read More

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