Bug 12248 – Static arrays have no tail const

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-02-25T02:31:00Z
Last change time
2014-02-25T07:14:47Z
Keywords
rejects-valid
Assigned to
nobody
Creator
dlang-bugzilla

Comments

Comment #0 by dlang-bugzilla — 2014-02-25T02:31:51Z
immutable(ubyte)[4] and immutable(ubyte[4]) are the same type. As a consequence, this won't compile: alias immutable(ubyte)[40] Hash; Hash[] hashes; hashes.sort; .sort (std.algorithm.sort too) does not compile, as it thinks the array contents is immutable.
Comment #1 by dlang-bugzilla — 2014-02-25T02:34:34Z
Wrapping the array in a struct causes .sort to work, but not std.algorithm.sort. Now I'm not sure what the bug is.
Comment #2 by bearophile_hugs — 2014-02-25T02:48:05Z
(In reply to comment #0) > immutable(ubyte)[4] and immutable(ubyte[4]) are the same type. As a > consequence, this won't compile: > > alias immutable(ubyte)[40] Hash; > Hash[] hashes; > hashes.sort; > > .sort (std.algorithm.sort too) does not compile, as it thinks the array > contents is immutable. This is expected. The values of the array are immutable, so you can't swap them.
Comment #3 by bearophile_hugs — 2014-02-25T02:49:48Z
(In reply to comment #1) > Wrapping the array in a struct causes .sort to work, but not > std.algorithm.sort. Now I'm not sure what the bug is. Please show the code that shows the difference. Also, never use the built-in sort, it's quite buggy, and it's going to be deprecated, hopefully warned-against in dmd 2.066.
Comment #4 by bearophile_hugs — 2014-02-25T07:14:47Z
(In reply to comment #3) > Please show the code that shows the difference. I have found it, filed as Issue 12253 I close this Issue because I think it's not a bug.