|
From: John R. <jr...@bi...> - 2015-08-01 06:01:35
|
> r2659:
> switch(ph->p_type) {
> ...
> case PT_INTERP: {
> ...
> for(j = 0; j < interp->e.e_phnum; j++) {
> ...
> }
> break;
>
> default: <---- misplaced
> // do nothing
> break;
> } // for case PT_INTERP
> } // for switch
>
> Do you agree with my findings?
Yes. Almost certainly the 'default' should not be inside the "{ ... }"
for "case PT_INTERP:".
For "safety belt" style, I like:
default: { // occurs FIRST and ALWAYS
...
} break;
case K: {
...
} break;
where EVERY 'case' and 'default' has braces and a following 'break'.
For fall-through:
case K: {
...
} // FALL THROUGH
> What I don't understand is why compiler does not flag this as an error?
It is legal C. https://en.wikipedia.org/wiki/Duff%27s_device#Mechanism
|