[Issue 24021] New: Issue a warning on assert with side effects

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jun 28 12:29:03 UTC 2023


https://issues.dlang.org/show_bug.cgi?id=24021

          Issue ID: 24021
           Summary: Issue a warning on assert with side effects
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: grimmaple95 at gmail.com

Consider this code:

```
bool fn(out int a)
{
    a = 10;
    return true;
}

void main()
{
    int a;
    assert(fn(a));
    writeln(a);
}
```

This code will behave differently in Release and Debug builds. I suggest
issuing a warning for the user, when caling functions with side-effects inside
an assertion. I'm aware of 6074, and I'm not talking about changing how asserts
work, but it would be great to have a warning about this.

--


More information about the Digitalmars-d-bugs mailing list