News for hackers. Stuff that matters.
Re:Catching use-after-move C++ bugs with Clang's consumed an... by rsp1984 on Thursday July 11, 2019 @02:42PM (#20414207)
> This is error-prone and a leak risk. You just made the code buggy

Well, that entirely depends on your skill and your overall design. But again, there's still vector<shared_ptr<SomeThing>> to the rescue if we need it.

> Avoiding std::move or insisting you don't need it is like scattering const_cast everywhere.

Strawman. I never said that. I said if you require std::move in a certain situation, have another look at your overall design. Again, same as const_cast.

Re:Catching use-after-move C++ bugs with Clang's consumed an... by kllrnohj on Friday July 12, 2019 @12:31AM (#20418183)
> Well, that entirely depends on your skill and your overall design.

If your argument against std::move & unique_ptr is "I don't make mistakes" then your ego is vastly too large to be a C++ developer.

The design doesn't change. unique_ptr just solidifies the design such that the compiler can help enforce the design.

> But again, there's still vector<shared_ptr<SomeThing>> to the rescue if we need it.

If you want to insist all heap allocates are always shared_ptr you can certainly do that. Personally I'd consider that dreadfully slow & expensive, and at that point you're far, far better off just using a GC'd language instead.

> I said if you require std::move in a certain situation, have another look at your overall design.

std::unique_ptr single handily proves this wrong.

Re:Catching use-after-move C++ bugs with Clang's consumed an... by rsp1984 on Friday July 12, 2019 @06:48AM (#20419677)
> If your argument against std::move & unique_ptr is "I don't make mistakes" then your ego is vastly too large to be a C++ developer.

Please stop the strawmans and polemics and allow your ego to consider the opinion of someone who is, in all likelihood, more experienced in shipping product written in C++.

> If you want to insist all heap allocates are always shared_ptr you can certainly do that. Personally I'd consider that dreadfully slow & expensive

Oh well. I have a feeling we're not going to agree. Maybe let's discuss again in a few years. Maybe I'll have tried std::move then and found that it is somewhat useful in certain special situations.

And maybe you'll have realized that the "dreadfully slow & expensive" shared_ptr doesn't make a difference in terms of end product quality in, I'd wager to say, 99.99% of situations.

> at that point you're far, far better off just using a GC'd language instead.

Uuhhm, no.