Why my gcc compiler doesn't issue error when I use break after return 0? (KNK Question)

Viewed 54

In the book C Programming by K.N.King,

...

case 3: printf("Current balance: $%.2f\n", balance); 
        break;
case 4: return 0;
default: printf("Commands: ...");
         break;

...

Note that the return statement is not followed by a break statement. A break immediately following a return can never be executed, and many compilers will issue a warning message.

I expected my compiler (usually GCC) would issue a warning message, so I deliberately use break statement in my program right after the return statement to 0 as below.

case  4:  printf("Exit the program\n");
    return 0;
    break;      /*** My gcc compiler doesn't issue any error ***/

But my compiler didn't make any error message like below.

C:\Users\user>gcc -Wall -w -o balance balance.c
/* Normally compiled */

Does my GCC compiler have problem? If not, Did the book by K.N.K not reflect recent compiler version?

0 Answers
Related