digitalmars.D.bugs - [Issue 224] New: Incorrect warning "no return at end of function"
- d-bugmail puremagic.com (22/22) Jun 25 2006 http://d.puremagic.com/issues/show_bug.cgi?id=224
- d-bugmail puremagic.com (9/9) Jun 25 2006 http://d.puremagic.com/issues/show_bug.cgi?id=224
- d-bugmail puremagic.com (9/9) Jul 09 2008 http://d.puremagic.com/issues/show_bug.cgi?id=224
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 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 Fixed dmd 1.032 and 2.016 --
Jul 09 2008