"lh_mouse"<[email protected]> writes: > EDIT: since C99, reaching the } that terminates the main function returns a > value of 0. > > 'The returned value is undefined' is not true. If the return value is used(in > the case of main(), > the host environment cares about it),
I already said that undefined behavior arises if the returned value is used. OTOH, do yo know an environment where the exit code of an application is relevant for a toy program when executed from a shell? > you get undefined behavior and give the compiler and runtime > the right to do whatever they want to do including invoking something > like rm -rf /. I'm a bit tired of that hyperbole. In this case it is even more absurd than usual. You are effectively saying that returning certain values from main would cause the runtime to do very bad things. Such an environment is tragically broken, obviously. BTW, you can be pretty sure that every large C/C++ application you use contains cases of undefined behavior. Do you backup your hard disk and disconnect from the internet before executing them? :-) > Since gcc uses -std=gnu89 by default, it is not safe to omit return 0; in > main(). > > ISO/IEC 9899:201X Programming languages — C > 6.9.1 Function definitions > 12 If the } that terminates a function is reached, and the value of the > function call is used by > the caller, the behavior is undefined. Curious. On my copy of ISO/IEC 9899 6.9 is "Future language directions" and 6.9.1 is "External names". In 6.7.1 "Function definitions" I see nothing relevant. In "The ANSI C Programming Language", page 203, it is said: "Flowing off the end of a function is equivalent to a return with no expression. In either case, the return value is undefined." ------------------------------------------------------------------------------ Want fast and easy access to all the code in your enterprise? Index and search up to 200,000 lines of code with a free copy of Black Duck Code Sight - the same software that powers the world's largest code search on Ohloh, the Black Duck Open Hub! Try it now. http://p.sf.net/sfu/bds _______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
