Nikolay Igotti
C mini-contest
Go guess, what's behaviour of this code:
int foo() {
while (0) while (1) while (2) ;
}
and this
int foo() {
while (2) while (1) while (0) ;
}
Both are valid C constructs, of course.
PS: Question itself is rather trivial, but at least to me it demonstrates important aspects of how dangerous implicit boundaries of C statements could be.
PPS: actually code which inspired me on this example was this comparison:
while (1) { } while (0);
do { } while (0);
which looking structurally same in fact are parsed completely differently
Posted at 04:32PM Jul 03, 2007 by nike in Personal | Comments[6]
Tuesday Jul 03, 2007
Posted by Gopal Venkatesan on July 03, 2007 at 05:08 PM MSD #
Posted by Michael van der Westhuizen on July 03, 2007 at 05:56 PM MSD #
Posted by Ashish Shukla on July 03, 2007 at 07:33 PM MSD #
Posted by nike on July 04, 2007 at 12:53 AM MSD #
Rgds
Damon
Posted by Damon Hart-Davis on July 04, 2007 at 02:38 AM MSD #
Posted by Jeff Bailey on July 07, 2007 at 10:57 PM MSD #