[Issue 3077] crash exiting main() without result code
https://issues.dlang.org/show_bug.cgi?id=3077 Andrei Alexandrescu changed: What|Removed |Added Version|unspecified |D2 --
[Issue 3077] crash exiting main() without result code
http://d.puremagic.com/issues/show_bug.cgi?id=3077 Walter Bright changed: What|Removed |Added Status|REOPENED|RESOLVED Resolution||FIXED --- Comment #5 from Walter Bright 2009-09-03 13:39:14 PDT --- Fixed dmd 2.032 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 3077] crash exiting main() without result code
http://d.puremagic.com/issues/show_bug.cgi?id=3077 Koroskin Denis <2kor...@gmail.com> changed: What|Removed |Added CC||2kor...@gmail.com Severity|normal |enhancement -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 3077] crash exiting main() without result code
http://d.puremagic.com/issues/show_bug.cgi?id=3077 Andrei Alexandrescu changed: What|Removed |Added Status|RESOLVED|REOPENED Resolution|INVALID | --- Comment #4 from Andrei Alexandrescu 2009-06-23 15:57:19 PDT --- (In reply to comment #3) > If main() was typed to return a void, as a special case then the compiler will > insert a: >return 0; > statement at the end. > > But if a function is typed to return an int, then that's a contract saying the > programmer must put in some sort of return statement. If there is none, the > compiler inserts a: >assert(0, "missing return expression"); > at the end. > > If you compile with -w, the compiler will warn you about this. (The compiler > doesn't always do this because it is perfectly legal for a function that is > typed to return an int to never return, such as if it calls abort().) > > When compiling in release mode, assert(0) is replaced with a HLT instruction, > which generates a hardware exception at runtime. This is what you're seeing. > > It's expected behavior. Not a bug. Thanks for the explanation. It does not do the least in making things better. Bad behavior is bad behavior, period. I am reopening the bug. This is important. It cost me and it could cost anyone precious time. Crashing at runtime without file and line information is the least effective of all ways to signal that the programmer has a bug in the program, by a large margin. Allowing a function to compile without a proper return is unreasonable. The diagnostic and refusal to generate code should not be relegated to -w. That state of affairs originates in the days when dmd's had much worse flow checking so it would signal a lot of false errors. Now dmd has good enough control flow checking to penalize all missing returns with a compile-time error, at the cost of requiring the occasional unnecessary insertion of an unreachable return statement. By this bug report I am requesting to move the "function has no return statement" diagnostic from -w mode to regular mode. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 3077] crash exiting main() without result code
http://d.puremagic.com/issues/show_bug.cgi?id=3077 Walter Bright changed: What|Removed |Added Status|NEW |RESOLVED Resolution||INVALID --- Comment #3 from Walter Bright 2009-06-23 13:15:25 PDT --- If main() was typed to return a void, as a special case then the compiler will insert a: return 0; statement at the end. But if a function is typed to return an int, then that's a contract saying the programmer must put in some sort of return statement. If there is none, the compiler inserts a: assert(0, "missing return expression"); at the end. If you compile with -w, the compiler will warn you about this. (The compiler doesn't always do this because it is perfectly legal for a function that is typed to return an int to never return, such as if it calls abort().) When compiling in release mode, assert(0) is replaced with a HLT instruction, which generates a hardware exception at runtime. This is what you're seeing. It's expected behavior. Not a bug. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 3077] crash exiting main() without result code
http://d.puremagic.com/issues/show_bug.cgi?id=3077 Walter Bright changed: What|Removed |Added CC||bugzi...@digitalmars.com --- Comment #1 from Walter Bright 2009-06-23 11:05:23 PDT --- I get the message: core.exception.asserter...@test.d(4): missing return expression Is that different from the one you get? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 3077] crash exiting main() without result code
http://d.puremagic.com/issues/show_bug.cgi?id=3077 --- Comment #2 from Andrei Alexandrescu 2009-06-23 11:08:15 PDT --- (In reply to comment #1) > I get the message: > > core.exception.asserter...@test.d(4): missing return expression > > Is that different from the one you get? Compile with -O -release -inline -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---