Dixit Oliver Kullmann (2005-11-15 16:30): > On Tue, Nov 15, 2005 at 11:23:15AM -0500, Pierre Sarrazin wrote: > > The following code generates the warning "control reaches end of > > non-void function" under g++ 3.4.2: > > > > int g() > > { > > } > > > > Why is this only a warning and not an error? > > Simply because this is legal code. Interesting. Do you happen to have a source I could go read myself? It seems like I need a refresher course... I asked someone to compile this code under Visual Studio .Net and that compiler gives an error (C4716: "must return a value"). I understand that we sometimes want to code functions like this one: int f() { exit(1); } But that seems relatively rare, and I for one would not mind being forced to add a dummy return statement after the call to exit(). The benefit of having a more rigorous compiler would outweigh this slight inconvenience. -- Pierre Sarrazin <sarrazip at sympatico dot ca>