Compiler analysis fault?

Dennis dkorpel at gmail.com
Wed Dec 20 12:45:26 UTC 2023


On Wednesday, 20 December 2023 at 11:33:22 UTC, DLearner wrote:
> The code below fails to compile with
>  Error: function `test1.foo` no `return exp;` or `assert(0);` 
> at end of function
> unless the commented-out assert(0) is included.

The compiler basically gives up control flow analysis when 
encountering a goto statement or labeled break/continue.
```D
bool foo()
{
    while(true)
    {
         L2:
         goto L2;
    }
//   assert(0);
}
```


More information about the Digitalmars-d-learn mailing list