Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!zaphod.mps.ohio-state.edu!menudo.uh.edu!svec5 From: svec5@menudo.uh.edu (T.C. Zhao) Newsgroups: comp.lang.c Subject: Re: C puzzle Message-ID: <1991Jun20.010011.18425@menudo.uh.edu> Date: 20 Jun 91 01:00:11 GMT References: <4007@d75.UUCP> Organization: University of Houston Lines: 27 In article <4007@d75.UUCP> thomas@advent.uucp () writes: > > The following is an interesting 'C' puzzle. > Consider this typical switch statement, typical except that > 'default' is misspelled 'defalut'! What is interesting is that > any C compiler will not and should not give you a syntax error. > Why? > > > switch (cmd) > { > case GO: > ... > break; > case STOP: > ... > break; > defalut: > printf ("Unknown command\n"); > break; > } Well, it depends. If defalut is never referenced, some compilers with certain switches might produce a warning: unreferenced label or unreachable code. I have not seen any C compiler like this( it is my impression that Fortran compiler tends to warn this kind of unreferenced stuff), but I wish my compiler would warn.