The @@@BUG@@@ the size of China - std.conv.d - Target parse(Target, Source)(ref Source s, uint radix)
anonymous via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Dec 7 14:32:38 PST 2015
On 07.12.2015 21:56, John Carter wrote:
> So whilst attempt to convert from a hex string (without the 0x) to int I
> bumped into the @@@BUG@@@ the size of China....
>
> https://github.com/D-Programming-Language/phobos/blob/master/std/conv.d#L2270
>
>
> Is there a bugzilla issue number tracking this?
>
> Searching for conv and parse in the issue tracker didn't turn it up....
>
> Is this a phobos bug or a compiler bug?
>
> I followed the example in the unit test to get a workaround.... but I
> don't understand why the workaround works!
I'm not sure if there's a bug. `parse` takes the string via `ref`, but
string literals are not lvalues so they cannot be passed that way. This
should also make it clear why the workaround works: A string literal is
not an lvalue, but a variable is.
Maybe whoever added that note thinks that string literals should be
lvalues. That would make it a compiler bug. I think that would be a
controversial viewpoint, though.
Or the author thinks that `parse` should work with non-lvalues. That
would make it a phobos issue. We have std.conv.to for that, though. So
weakening the requirements on `parse` isn't exactly necessary. Just use
`to` when you don't care about popping the input.
More information about the Digitalmars-d-learn
mailing list