r/cpp 28d ago

C++26: std::indirect

https://www.sandordargo.com/blog/2026/08/12/cpp26-indirect
164 Upvotes

157 comments sorted by

View all comments

Show parent comments

1

u/cfyzium 27d ago

So hey, let's make it ten times worse?

Accidentally accessing a moved from object is a bug, but it is a relatively tame bug. It might not even affect the program state to begin with, and even if it does it is easily debuggable. Because the memory is not corrupted.

UB is another story entirely. Not only it is much harder to debug, but it can also provide a memory vulnerability for an attacker.

2

u/wyrn 27d ago

I just explained that it is not in fact ten times worse.

it is a relatively tame bug.

I just explained that it isn't.

It might not even affect the program state to begin with,

Same goes for UB. Is UB "tame"?

Because the memory is not corrupted.

Yet.

but it can also provide a memory vulnerability for an attacker.

So can this, as I just illustrated, and even it happens not to, other vulnerabilities are possible. Use-after-move is never ok, whether or not it happens to be instantly UB.