Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversion error for ulong -> uint (as a size_t) on 32-bit linux #4

Open
PiotrekDlang opened this issue Feb 27, 2015 · 4 comments
Open

Comments

@PiotrekDlang
Copy link

What is current policy for dealing with ulong -> size_t conversion?

dmd -main -unittest allocator.d

allocator.d(2015): Error: cannot implicitly convert expression (i * 4096LU) of type ulong to uint
allocator.d(2015): Error: cannot implicitly convert expression ((i + cast(ulong)blocks) * 4096LU) of type ulong to uint
allocator.d(1743): Error: template instance std.allocator.HeapBlock!(4096u, 4u)
allocator.d(331): instantiated from here: HeapBlock!(4096u, 4u)
allocator.d(334): Error: template instance Segregator!
allocator.d(2015): Error: cannot implicitly convert expression (i * 128LU) of type ulong to uint
allocator.d(2015): Error: cannot implicitly convert expression ((i + cast(ulong)blocks) * 128LU) of type ulong to uint
allocator.d(1743): Error: template instance std.allocator.HeapBlock!(128u, 4u)
allocator.d(1342): instantiated from here: HeapBlock!(128u, 4u)
allocator.d(1493): Error: cannot implicitly convert expression (x / 64LU) of type ulong to immutable(uint)
allocator.d(1495): Error: cannot implicitly convert expression (y / 64LU) of type ulong to immutable(uint)
allocator.d(1520): Error: cannot implicitly convert expression (x / 64LU) of type ulong to uint
allocator.d(1526): Error: cannot implicitly convert expression (i) of type ulong to uint
allocator.d(1527): Error: cannot implicitly convert expression (i) of type ulong to uint
allocator.d(1544): Error: cannot implicitly convert expression (w) of type ulong to uint
allocator.d(1553): Error: cannot implicitly convert expression (w) of type ulong to uint
allocator.d(1572): Error: cannot implicitly convert expression (w) of type ulong to uint
allocator.d(1582): Error: cannot implicitly convert expression (w) of type ulong to uint
allocator.d(1607): Error: cannot implicitly convert expression (i) of type ulong to uint
allocator.d(1615): Error: cannot implicitly convert expression (i) of type ulong to uint
allocator.d(1627): Error: cannot implicitly convert expression (i) of type ulong to uint
allocator.d(1633): Error: cannot implicitly convert expression (i) of type ulong to uint
allocator.d(4143): Error: function std.allocator.roundUpToMultipleOf (uint s, uint base) is not
callable using argument types (ulong, uint)

@MartinNowak
Copy link
Collaborator

Maybe the code wasn't tested on a 32-bit machine?
Andrei doesn't maintain this repo and instead develops in one of his Phobos branches.
AFAIK, he currently prepares std.allocator for inclusion in std.experimental.

@PiotrekDlang
Copy link
Author

Thanks Martin for stopping by.

Maybe the code wasn't tested on a 32-bit machine?

The fix may be trivial however I wanted to ask for official approach to the conversion issues from size_t real types.
I plan to include the module in

https://github.com/D-Programming-Language-Labs/Curiosity

Andrei doesn't maintain this repo and instead develops in one of his Phobos branches.

Yeah, that confused me as I initially indeed checked his Phobos branch. And there is no issue tracker enabled.

@PiotrekDlang
Copy link
Author

Just FYI. I played a bit with the code and after changing the problematic ulongs to size_t I had to comment out a few asserts and a couple of crashing tests. Maybe I will prepare a PR to the proper repo tomorrow or a day after. You can safely ignore this thread for some time.

@PiotrekDlang
Copy link
Author

andralex/phobos#6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants