Blog

Tag Archives: c99

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

Solution to yesterday's quiz
Pascal Cuoq on 29 November 2012

Yesterday's quiz was about the expression *(char*)(float[]){x*x} - 63 (for big-endian architectures) or *(3+(char*)(float[]){x*x}) - 63 (for little-endian ones). This post provides an explanation. First, let us try the function on a few values: int main(){ for (unsigned int i=0; i<=20; i++) printf(\l(%2u)=%d" i l(i)); } This may provide the...

Read More

C99 quiz
Pascal Cuoq on 28 November 2012

Here is a convenient one-liner: int l(unsigned int x) { return *(char*)(float[]){x*x} - 63; } What does it do on my faithful PowerMac? The Intel version is not as nice. That's progress for you: *(3+(char*)(float){x*x}) - 63

Read More