Hi,

Today I have just found a weird bug in std.logger. Consider:

```d
import std.logger : info;

void main() {
    info(foo());
}

auto foo() {
    info("In foo");
    return "Hello, world.";
}
```

The output is:

```
2023-10-31T20:41:05.274 [info] onlineapp.d:8:foo In foo
2023-10-31T20:41:05.274 [info] onlineapp.d:8:foo In fooHello, world.
```

The second line is obviously wrong, as it repeats the first line as its header. That's why I suspect memory corruption.

Assigning the value to a variable works as expected:

```d
import std.logger : info;

void main() {
    auto s = foo();
    info(s);
}

auto foo() {
    info("In foo");
    return "Hello, world.";
}
```

gets the proper output:

```
2023-10-31T21:09:46.529 [info] onlineapp.d:9:foo In foo
2023-10-31T21:09:46.529 [info] onlineapp.d:5:main Hello, world.
```

I can only imagine that it's related to the logging functions taking lazy arguments, although I cannot see why it would be a problem in a simple case like this.

Reply via email to