[Issue 9629] toUpperInPlace doesn't work properly with unicode characters

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Mar 4 23:51:27 PST 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9629



--- Comment #4 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2013-03-04 23:51:22 PST ---
(In reply to comment #3)
> At a glance, it looks to me like the problem is this line:
> 
>   s = s[0 .. i] ~ toAdd  ~ s[j .. $];
> 
> See, it's not overwriting any memory, it's allocating and writing into new
> memory... that contradicts the 'InPlace' specification.
> 
> Shouldn't that line be more like:
>   s[i .. j] = toAdd[];
> 
> And I don't think there's any reason for the function to receive a 'ref'.

Hmm yeah that's the problem. It's kind of odd that a slice which only really
lives inside the function is allowed to be passed by ref. What I mean is:

void foo(ref int[] a) { }
int[] a = [1, 2];
foo(a[0..2]);

It seems like this kind of slice should be treated as an rvalue, because ref
semantics make no sense in this case as they won't propagate to the call site.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list