Re: std.string.assumeUTF() silently casting mutable to immutable?

2024-02-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, February 13, 2024 12:40:57 AM MST Forest via Digitalmars-d-learn wrote: > I may have found a bug in assumeUTF(), but being new to D, I'm > not sure. > > The description: > > Assume the given array of integers arr is a well-formed UTF > > string and return it typed as a UTF string. > >

Re: std.string.assumeUTF() silently casting mutable to immutable?

2024-02-13 Thread Johan via Digitalmars-d-learn
On Tuesday, 13 February 2024 at 08:10:20 UTC, Jonathan M Davis wrote: So, there's definitely a bug here, but it's a dmd bug. Its checks for whether it can safely change the constness of the return type apparently aren't sophisticated enough to catch this case. This is a pretty severe bug. S

Re: length's type.

2024-02-13 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Feb 13, 2024 at 06:36:22PM +, Nick Treleaven via Digitalmars-d-learn wrote: > On Monday, 12 February 2024 at 18:22:46 UTC, H. S. Teoh wrote: [...] > > Honestly, I think this issue is blown completely out of proportion. > > The length of stuff in any language needs to be some type. D de

Re: length's type.

2024-02-13 Thread Ivan Kazmenko via Digitalmars-d-learn
On Monday, 12 February 2024 at 19:56:09 UTC, H. S. Teoh wrote: But regardless, IMNSHO any programmer worth his wages ought to learn what an unsigned type is and how it works. A person should not be writing code if he can't even be bothered to learn how the machine that's he's programming actual

Re: length's type.

2024-02-13 Thread Kevin Bailey via Digitalmars-d-learn
On Tuesday, 13 February 2024 at 23:57:12 UTC, Ivan Kazmenko wrote: I'd like to note that even C++20 onwards has `.ssize`, which is signed size. I do use lengths in arithmetic sometimes, and that leads to silent bugs currently. On the other hand, since going from 16 bits to 32 and then 64,

Re: std.string.assumeUTF() silently casting mutable to immutable?

2024-02-13 Thread Forest via Digitalmars-d-learn
On Tuesday, 13 February 2024 at 14:05:03 UTC, Johan wrote: On Tuesday, 13 February 2024 at 08:10:20 UTC, Jonathan M Davis wrote: So, there's definitely a bug here, but it's a dmd bug. Its checks for whether it can safely change the constness of the return type apparently aren't sophisticated