Thread overview
warning bug in dmd 0.17
Feb 08, 2006
braddr
Feb 14, 2006
braddr
Feb 14, 2006
braddr
February 08, 2006
Two test cases that I suspect are the same bug:

==== bug1.d ====
class F { }
int foo() {
auto F f = new F(); // comment out and warning goes away
return 0;
}
====
$ gdc -g -Wall -c bug1.d
warning - bug1.d:2: function bug1.foo no return at end of function

On a hunch..

==== bug2.d ====
int foo() {
try {
return 0;
} finally { }
}
====
$ gdc -g -Wall -c bug2.d
warning - bug2.d:1: function bug2.foo no return at end of function

neither of these produces a warning with dmd 0.145

Later,
Brad


February 14, 2006
In article <dscd6h$14pe$1@digitaldaemon.com>, braddr@puremagic.com says...
>
>Two test cases that I suspect are the same bug:
>
>==== bug1.d ====
>class F { }
>int foo() {
>auto F f = new F(); // comment out and warning goes away
>return 0;
>}
>====
>$ gdc -g -Wall -c bug1.d
>warning - bug1.d:2: function bug1.foo no return at end of function
>
>On a hunch..
>
>==== bug2.d ====
>int foo() {
>try {
>return 0;
>} finally { }
>}
>====
>$ gdc -g -Wall -c bug2.d
>warning - bug2.d:1: function bug2.foo no return at end of function
>
>neither of these produces a warning with dmd 0.145
>
>Later,
>Brad

Ok, my initial report of this not being a general bug with both gdc and dmd was wrong.  I tried this myself with dmd and it _does_ occur with it as of 0.146 as well.  I didn't try with earlier versions.

So.. cc'ing digitalmars.D.bugs to expand the scope of the report.

I'll try to dig in and find this as time permits.

Later,
Brad


February 14, 2006
In article <dsrojl$oi2$1@digitaldaemon.com>, braddr@puremagic.com says...
>
>In article <dscd6h$14pe$1@digitaldaemon.com>, braddr@puremagic.com says...
>>
>>Two test cases that I suspect are the same bug:
>>
>>==== bug1.d ====
>>class F { }
>>int foo() {
>>auto F f = new F(); // comment out and warning goes away
>>return 0;
>>}
>>====
>>$ gdc -g -Wall -c bug1.d
>>warning - bug1.d:2: function bug1.foo no return at end of function
>>
>>On a hunch..
>>
>>==== bug2.d ====
>>int foo() {
>>try {
>>return 0;
>>} finally { }
>>}
>>====
>>$ gdc -g -Wall -c bug2.d
>>warning - bug2.d:1: function bug2.foo no return at end of function
>>
>>neither of these produces a warning with dmd 0.145
>>
>>Later,
>>Brad
>
>Ok, my initial report of this not being a general bug with both gdc and dmd was wrong.  I tried this myself with dmd and it _does_ occur with it as of 0.146 as well.  I didn't try with earlier versions.
>
>So.. cc'ing digitalmars.D.bugs to expand the scope of the report.
>
>I'll try to dig in and find this as time permits.
>
>Later,
>Brad

I think I've found a fix for the problem:

2494 int TryFinallyStatement::fallOffEnd()
2495 {   int result;
2496
2497     result = body->fallOffEnd();
2498     if (finalbody)
>>>2499         result &= finalbody->fallOffEnd();
2500     return result;
2501 }

line 2499 originally lacked the &.

Looking at other ::fallOffEnd methods, a few of them seem questionable, but I haven't thought through them enough to say that there are bugs.

A quick scan without having constructed test cases:

Statement::fallOffEnd
-- should that also be falloff &= s->fallOffEnd(); so that once it's determined
that it _doesn't_ fall off, that it keeps track of that?

WhileStatement::fallOffEnd
DoStatement::fallOffEnd
ForStatement::fallOffEnd
ForeachStatement::fallOffEnd
SwitchStatement::fallOffEnd
-- they don't all fall off the end, shouldn't it be:
>>return<< body->fallOffEnd()
-- in While and Do forms, can body be null?  For[each] has a check but the others don't.

Later,
Brad