Thread overview |
---|
June 25, 2006 [Issue 224] New: Incorrect warning "no return at end of function" | ||||
---|---|---|---|---|
| ||||
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. -- |
June 25, 2006 [Issue 224] Incorrect warning "no return at end of function" | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | 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. -- |
July 10, 2008 [Issue 224] Incorrect warning "no return at end of function" | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | 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 -- |
Copyright © 1999-2021 by the D Language Foundation