[swift-users] inout params seem to have undefined behavior
Joe Groff
jgroff at apple.com
Mon Jun 13 15:43:45 CDT 2016
> On Jun 13, 2016, at 1:39 PM, Jens Alfke <jens at mooseyard.com> wrote:
>
>
>> On Jun 13, 2016, at 9:45 AM, Joe Groff via swift-users <swift-users at swift.org> wrote:
>>
>> It's not undefined behavior in that we try to ensure that memory safety is still preserved when inout parameters alias, but it is *unspecified* when updates to an inout parameter will be written back to the original argument.
>
> But it seems that memory safety was broken in that an array assigned to a ‘let’ variable was mutated. Doesn’t that violate the contract of its immutability?
I see, missed that part. That's a bug—`acopy` should remain a distinct copy of `a`.
-Joe
More information about the swift-users
mailing list