### Suspicious Assignments and Incorrect Function Returns

If you enable the Extended Error Checking setting, the C compiler generates a warning if it encounters one of the following potential problems:

- A non-void function that does not contain a return statement. For example, the source code in Listing 1 generates a warning.

> Listing 1. Non-void Function with no return Statement

> main() /* assumed to return int */
> {
> printf ("hello world\n");
> } /* WARNING: no return statement */
> Listing 6.8 does not generate a warning.
> Listing 6.8 Explicitly Specifying a Function’s void Return Type
> void main() /* function declared to return void */
> {
> printf ("hello world\n");
> }

- An integer or floating-point value assigned to an enum type. Listing 2 shows an example.

> ##### Listing 2. Assigning to an Enumerated Type

> enum Day { Sunday, Monday, Tuesday, Wednesday,
> Thursday, Friday, Saturday } d;

> d = 5; /* WARNING */
> d = Monday; /* OK */
> d = (Day)3 ; /* OK */
> • An empty return statement in a function that is not declared void. For example, the following code results in a warning:
> int MyInit(void)
> {
> int err = GetMyResources();
> if (err!=0) return; /* ERROR: Empty return statement */

> /* ... */
> This is OK:
> int MyInit(void)
> {
> int err = GetMyResources();
> if (err!=0) return -1; /* OK */

> /* ... */

The Extended Error Checking setting corresponds to the pragma extended_errorcheck, described at extended_errorcheck. To check this setting, use __option (extended_errorcheck).

See Checking Option Settings for information on how to use this directive.