News for hackers. Stuff that matters.
Re:Regression in Linux 4.14 – using bcache can destroy the f... by bonzini on Tuesday November 21, 2017 @04:29PM (#15751761)
A language with copy constructors doesn't prevent you from putting a bug in them.

C++ or Rust might have put a 0 in the uninitialized member, but the bug would have remained.

Re:Regression in Linux 4.14 – using bcache can destroy the f... by steveklabnik on Tuesday November 21, 2017 @06:01PM (#15752458)
Rust doens't have copy constructors, to be clear.
Re:Regression in Linux 4.14 – using bcache can destroy the f... by masklinn on Wednesday November 22, 2017 @05:33AM (#15755793)
> A language with copy constructors doesn't prevent you from putting a bug in them.

If you don't override it, it will copy everything properly.

> Rust might have put a 0 in the uninitialized member

Rust does not do that. If a member is not initialised, it's uninitialised and in this case the structure will be rejected. Here even if you could not just have derived Clone (struct bio looks non-trivial) your hand-rolled implementation would have complained that you had not properly initialised the member.

Re:Regression in Linux 4.14 – using bcache can destroy the f... by bonzini on Wednesday November 22, 2017 @11:21AM (#15757982)
> If you don't override it, it will copy everything properly.

Sure, so does memcpy or bare struct assignment in C. The problem is that trivial copy constructors are relatively rare.

> Here even if you could not just have derived Clone (struct bio looks non-trivial) your hand-rolled implementation would have complained that you had not properly initialised the member.

Right, but this is more similar to an assignment operator. DerefMut in Rust I think wouldn't have caught the bug.

Re:Regression in Linux 4.14 – using bcache can destroy the f... by masklinn on Wednesday November 22, 2017 @11:53AM (#15758273)
> Right, but this is more similar to an assignment operator.

Only if you don't zoom out. If you do, this is alloc/init/fill which in C++ or Rust would use a regular copy and RVO.