RE: Compiler didn't error on function with no return statement

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

 



> 
> <http://stackoverflow.com/questions/5655181/how-to-turn-on-gcc-
> warnings-for-a-forgotten-return-statement>
> 
> Failing to provide a return value is legal C, but undefined behaviour.
> So gcc has to accept it.
> 
> You only get warnings if you enable them.  Normally, you will want your
> code to be warning-free when compiled with "-Wall".  Many people use "-
> Wextra" as well - I personally enable many of the other warning flags
> as well.
> 

David,

Thanks for the explanation.  I figured it had to be something like this.  It's rather humorous that it's legal but undefined.  It would seem that anything "legal" must, by requirement, have a definition.  One thing I don't quite understand about this behavior of gcc, as I understand the function of gcc it calls the appropriate compiler based on file name suffix.  Since this isn't legal C++, why isn't a warning or error generated by the C++ compiler of gcc?  Am I misunderstanding something about gcc's operation?

Andy





[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