RE: Control reaches end of non-void function: why only a warning?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Not a bad idea, but in many situations, I am compiling a large
> project whose code generates many warnings, and turning them all
> into errors would be unworkable.

Use -Werror with only the specific warning option (-Wreturn-type) turned on.
Fix the warnings, remove -Werror and add back in the other warning options.

> I have patched my copy of the gcc sources to turn this warning
> into an error, but I'm still curious to see an example of when it
> is useful to knowingly allow the control flow to leave a function
> with an undefined return value.

There could be a function with a control flow that returns something useful
in one path and something meaningless in another. Or a function calls
another function that never returns (exit example).  It is more important
for a compiler to follow the language standard and accept valid source than
it is to have a compiler that tries to enforce good programming practises
and design. There are plenty of static analysis tools for checking c
programs available (lint/splint/etc).

Regards,

Ryan Mansfield


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux