digitalmars.D.bugs - [Issue 224] New: Incorrect warning "no return at end of function"
- d-bugmail puremagic.com Jun 25 2006
- d-bugmail puremagic.com Jun 25 2006
- d-bugmail puremagic.com Jul 09 2008
http://d.puremagic.com/issues/show_bug.cgi?id=224 Summary: Incorrect warning "no return at end of function" Product: D Version: 0.161 Platform: PC OS/Version: Windows Status: NEW Keywords: diagnostic, rejects-valid Severity: minor Priority: P3 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: deewiant gmail.com int main() { // or for (;;), or while (true), or do...while(true); if (true) return 0; } Such code generates (when compiled with -w) the warning "function module.main no return at end of function". But, of course, if allowed to compile, the function would return 0. --
Jun 25 2006
http://d.puremagic.com/issues/show_bug.cgi?id=224 ------- Comment #1 from jarrett.billingsley gmail.com 2006-06-25 16:21 ------- With the simplistic flow analysis in D (read: virtually none), it can't tell that the conditional is always taken. That if statement might not be optimized out until after the function "flow analysis" is done. Which is why this is a warning and not an error, or else it'd probably give the same warning for half the functions that you write. All it checks for is if the last statement of the function is a return, and in this case, it isn't. --
Jun 25 2006
http://d.puremagic.com/issues/show_bug.cgi?id=224 bugzilla digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED ------- Comment #2 from bugzilla digitalmars.com 2008-07-09 22:31 ------- Fixed dmd 1.032 and 2.016 --
Jul 09 2008









d-bugmail puremagic.com 