D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6446 - Problem with iota(long)
Summary: Problem with iota(long)
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: x86 Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2011-08-06 19:47 UTC by bearophile_hugs
Modified: 2017-09-07 12:50 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2011-08-06 19:47:58 UTC
I think this is a bug of iota() (or a problem in core.memory.GC.malloc):


import std.range: iota;
import std.array: array;
void main() {
    auto a = array(iota(1L));
}



DMD gives:

...\std\array.d(243): Error: function core.memory.GC.malloc (uint sz, uint ba = cast(uint)0) is not callable using argument types (ulong,BlkAttr)
...\std\array.d(243): Error: cannot implicitly convert expression (_param_0 * 8LU) of type ulong to uint
...\std\array.d(231): Error: cannot implicitly convert expression (_param_0) of type ulong to uint
...\std\array.d(194): Error: template instance std.array.arrayAllocImpl!(false,long[],ulong) error instantiating
...\std\array.d(42):        instantiated from here: uninitializedArray!(long[],ulong)
test.d(4):        instantiated from here: array!(Result)
...\std\array.d(42): Error: template instance std.array.uninitializedArray!(long[],ulong) error instantiating
test.d(4):        instantiated from here: array!(Result)
test.d(4): Error: template instance std.array.array!(Result) error instantiating
Comment 1 Jonathan M Davis 2011-08-06 19:56:13 UTC
It compiles just fine with the latest master. I believe that that iota was taking a size_t before, which then didn't work with long on 32-bit systems. It was fixed in

https://github.com/D-Programming-Language/phobos/commit/d08f0e6621e1ceb1d8a4cded975507f775c8857e

I think that there was a bugzilla entry that went with it, but it's not in the changelog, so I don't know what it was.
Comment 2 bearophile_hugs 2011-08-07 05:08:24 UTC
I have just compiled the latest DMD, druntime and Phobos, and I see some errors still. Maybe it's my fault, I don't know.
Comment 3 SomeDude 2012-04-26 11:30:07 UTC
This still doesn't compile on 2.059 Win32
Comment 4 hsteoh 2014-08-07 21:39:30 UTC
Works on git HEAD (2.067a) on Linux/64.
Comment 5 hsteoh 2014-11-04 00:06:56 UTC
Unable to reproduce on git HEAD, Linux/64. Does this bug still happen? Can anyone else try to reproduce it (on Windows)?
Comment 6 bearophile_hugs 2014-11-04 01:05:15 UTC
(In reply to hsteoh from comment #5)
> Unable to reproduce on git HEAD, Linux/64. Does this bug still happen? Can
> anyone else try to reproduce it (on Windows)?

On Windows32 now this gives:


void main() {
    import std.range: iota;
    import std.array: array;
    auto a = 1L.iota.array;
}



...\dmd2\src\phobos\std\array.d(47,43): Error: function std.array.array!(Result).array.trustedAllocateArray (uint n) is not callable using argument types (ulong)
test.d(4,21): Error: template instance std.array.array!(Result) error instantiating
Comment 7 RazvanN 2017-09-07 12:50:28 UTC
I just compiled and ran the exmample successfully with the latest dmd, druntime, phobos on linux 64-bit and with wine for windows 32 bit. Closing as WORKSFORME.