On Sunday, 24 August 2025 at 15:29:01 UTC, Steven Schveighoffer wrote:
```
import std.stdio;

void main() {
    string * ptrSum = &parenthesized("2 + 3");
        string sum = parenthesized("4 * 5");

    writefln("ptrSum : %s %s", ptrSum, *ptrSum);
    writefln("sum    : %s", sum);
}

auto ref string parenthesized(string phrase) {
    string result = '(' ~ phrase ~ ')';
        writeln("&result: ", &result);
    return result;      // ← compilation ERROR
}
```

I don't know what's happening here, but it seems like a bug. This should not compile (it does for me, despite the comment above).

Yes, I think it's https://github.com/dlang/dmd/issues/19893. If `parenthesized` is moved above `main`, I get:

```
Error: cannot take address of expression `parenthesized("2 + 3")` because it is not an lvalue
    string * ptrSum = &parenthesized("2 + 3");
                                    ^
```

Reply via email to