News for hackers. Stuff that matters.
Re:The C++ standard for the F-35 Fighter Jet [video] by dh2022 on Sunday December 07, 2025 @09:37PM (#46187701)
std::vector<int> allocated and freed on the stack will allocate an array for its int’s on the heap…
Re:The C++ standard for the F-35 Fighter Jet [video] by usefulcat on Monday December 08, 2025 @01:41AM (#46189144)
I've heard that MSVC does (did?) that, but if so that's an MSVC problem. gcc and clang don't do that.

https://godbolt.org/z/nasoWeq5M

Re:The C++ standard for the F-35 Fighter Jet [video] by menaerus on Monday December 08, 2025 @03:00AM (#46189608)
WDYM? Vector is an abstraction over dynamically sized arrays so sure it does use heap to store its elements.
Re:The C++ standard for the F-35 Fighter Jet [video] by aw1621107 on Monday December 08, 2025 @01:32PM (#46195886)
I think usefulcat interpreted "std::vector<int> allocated and freed on the stack" as creating a default std::vector<int> and then destroying it without pushing elements to it. That's what their godbolt link shows, at least, though to be fair MSVC seems to match the described GCC/Clang behavior these days.
Re:The C++ standard for the F-35 Fighter Jet [video] by Gupie on Monday December 08, 2025 @10:39AM (#46193524)
Sure, but my point was that RAII doesn't need to involve the heap. Another example would be acquiring abd releasing a mutex.