News for hackers. Stuff that matters.
Re:C++ std::move doesn't move anything: A deep dive into Val... by Fiveplus on Sunday January 11, 2026 @06:47AM (#46574833)
The reason performance-noexcept-move-constructor is not enabled by default is likely because blindly applying noexcept is dangerous if the underlying logic isn't actually exception-free. If you let clang-tidy slap noexcept on a move constructor that does end up throwing (perhaps because it calls into a legacy member or allocates memory internally), the runtime behavior changes from caught exception to std::terminate().
Re:C++ std::move doesn't move anything: A deep dive into Val... by immibis on Sunday January 11, 2026 @07:37AM (#46575219)
clang-tidy checks but doesn't change things for you.

Since you can also put noexcept(false) to indicate something throws exceptions and you didn't just forget to mark it noexcept, it's not a bad policy to say every move constructor should have a noexcept marker.

Re:C++ std::move doesn't move anything: A deep dive into Val... by phkahler on Sunday January 11, 2026 @07:22AM (#46575126)
Exceptions should never be enabled by default. We live in a 64bit world so allocations failing indicates some other problem.
Re:C++ std::move doesn't move anything: A deep dive into Val... by zbentley on Sunday January 11, 2026 @08:10AM (#46575439)
What does processor but width have to do with the likelihood of allocation failures?
Re:C++ std::move doesn't move anything: A deep dive into Val... by petcat on Sunday January 11, 2026 @08:55AM (#46575807)
640K ought to be enough for anybody!
Re:C++ std::move doesn't move anything: A deep dive into Val... by HarHarVeryFunny on Sunday January 11, 2026 @09:02AM (#46575851)
I think what he means is that on a 64-bit system you have a massive virtual address space (typically only 48-bit, but that's still 256TB), and since malloc allocates from virtual address space, not limited by physical memory, it is unlikely you will get a malloc failure (unless you are trying to allocate more than 256TB per process, maybe due to a memory leak).
Re:C++ std::move doesn't move anything: A deep dive into Val... by locknitpicker on Monday January 12, 2026 @02:31AM (#46585248)
> it is unlikely you will get a malloc failure

That assertion completely misses the point. The scenarios involving move constructors throwing exceptions involve objects being stuck in an inconsistent/zombie state. In fact, the whole point of a move constructors is to avoid having to allocate memory.

Re:C++ std::move doesn't move anything: A deep dive into Val... by zbentley on Tuesday January 13, 2026 @05:56PM (#46609577)
That's not true as generally as you might expect.

Folks might be using mmap with MAP_POPULATE; they might have overcommit turned off; they might be operating in an rlimit/cgroup (like most container runtimes/orchestrators configure) that limits memory; they might be on a system which doesn't have virtual memory (plenty such systems exist in 64-bit architectures); they might be using calloc on an OS that zeros pessimistically/early; and so on.

Re:C++ std::move doesn't move anything: A deep dive into Val... by usefulcat on Sunday January 11, 2026 @02:13PM (#46578796)
Exceptions can be used to indicate many kinds of errors, not just allocation failures.
Re:C++ std::move doesn't move anything: A deep dive into Val... by dbcpp on Sunday January 11, 2026 @09:30AM (#46576056)
I would argue performance-noexcept-move-constructor should always be on. Move constructors should almost always be noexcept since they typically just move pointers around and don't do allocations normally.
Re:C++ std::move doesn't move anything: A deep dive into Val... by jcelerier on Sunday January 11, 2026 @11:50AM (#46577305)
eh, depends. for instance think about a small_vector or small_string
Re:C++ std::move doesn't move anything: A deep dive into Val... by dbcpp on Sunday January 11, 2026 @11:55AM (#46577353)
True, in that case it should just inherit the noexcept status of the object it holds.
Re:C++ std::move doesn't move anything: A deep dive into Val... by HarHarVeryFunny on Sunday January 11, 2026 @10:14AM (#46576409)
The documentations seems to say that option only causes the compiler to issue a warning when move constructors are not marked noexcept - it doesn't override anything.

https://clang.llvm.org/extra/clang-tidy/checks/performance/n... constructor.html

Note that the way std::vector (and other STL containers) require noexcept move constructors for reallocation is by using template matching, and of course any other code might be doing this too, so having a compiler option that forced a constructor (or anything) to have a type signature different than the way it was declared would be a pretty dangerous thing to do since it'd be hard to know what the consequences would be.