Sunday, May 28, 2006

C oddity....

Found something similar while debugging a memory leak:
int main() {
    int x, y;
    switch(x) {
        case 0:
            break;
        case 1:
            if(y==5) {
        default:          // wtf. default inside if? 
            break;        // it seems to work for every
                          // compiler I used
        }
        case 2:
            break;
    }
    return 0;
}

1 comment:

  1. I am stupid. I have read the C99 standard and THIS is the correct behaviour.

    But still pretty odd...

    ReplyDelete