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

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

By this bug report I am requesting to move the "function has no return
statement" diagnostic from -w mode to regular mode.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to