//---- import std.string; void main() { auto a = iota(0, 10); auto p = &a; writefln("%s", a); writefln("%s", p); } //---- [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] //---- This is not documented behavior. The documented behavior is simply: "Pointers are formatted as hex integers." The current behavior (pointer to ranges prints the range) makes no sense to me, and I don't see why a pointer to such a type would get a special treatment. I think this behavior is wrong, and should be removed to simply treat the pointer as a pointer.
(In reply to comment #0) > This is not documented behavior. The documented behavior is simply: > "Pointers are formatted as hex integers." The fun is that a pointer to a range is a range. It naturally supports all of primitives. > I think this behavior is wrong, and should be removed to simply treat the > pointer as a pointer. Maybe.
(In reply to comment #1) > (In reply to comment #0) > > > This is not documented behavior. The documented behavior is simply: > > "Pointers are formatted as hex integers." > > The fun is that a pointer to a range is a range. It naturally supports all of > primitives. Almost ;) https://d.puremagic.com/issues/show_bug.cgi?id=11779 //---- import std.string; void main() { auto a = iota(0, 10).array(); auto p = &a; writefln("%s", a); writefln("%s", p); } //---- [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] 7FFF0ABA5FA0 //----
(In reply to comment #1) > (In reply to comment #0) > > > This is not documented behavior. The documented behavior is simply: > > "Pointers are formatted as hex integers." > > The fun is that a pointer to a range is a range. It naturally supports all of > primitives. Also (but off topic here), while the slicing operator is still supported, the slice-able *trait* becomes lost, as the returned type (R) won't match the used type (R*).
This bug made it more difficult for me to debug a separate issue because I could not print addresses of struct objects. I had to figure out this bug first.
@berni44 created dlang/phobos pull request #7305 "Fix Issue 11782 - format pointer to range prints range" fixing this issue: - Fix Issue 11782 - format pointer to range prints range https://github.com/dlang/phobos/pull/7305
dlang/phobos pull request #7305 "Fix Issue 11782 - format pointer to range prints range" was merged into master: - 738d15df38c2459381b89fac1a17f4b3fe2f6f14 by Bernhard Seckinger: Fix Issue 11782 - format pointer to range prints range https://github.com/dlang/phobos/pull/7305