News for hackers. Stuff that matters.
Re:DARPA: Translating All C to Rust (Tractor) by Calavar on Tuesday July 30, 2024 @12:51PM (#41111293)
As far as I am aware, the standard doesn't mandate bounds checking for std::vector::operator[] and probably never will for backwards compatibility reasons. Most standard library implementations have opt-out std::vector[] bounds checking in unoptimized builds, but not in optimized builds.

I tried a toy example with GCC [1], Clang [2], and MSVC [3], and none of them emit bounds checks with basic optimization flags.

[1] https://godbolt.org/z/W5e3n5oWM

[2] https://godbolt.org/z/Pe8nPPvEd

[3] https://godbolt.org/z/YTdv3nabn

Re:DARPA: Translating All C to Rust (Tractor) by TinkersW on Tuesday July 30, 2024 @08:38PM (#41115482)
As I said you need the correct flag set.. MSVC use _CONTAINER_DEBUG_LEVEL=1 and it can be used in release. They have had this feature since 2010 or so, though the flag name has changed.
Re:DARPA: Translating All C to Rust (Tractor) by pjmlp on Wednesday July 31, 2024 @08:06AM (#41118474)
The correct name is _ITERATOR_DEBUG_LEVEL.
Re:DARPA: Translating All C to Rust (Tractor) by pjmlp on Wednesday July 31, 2024 @08:09AM (#41118496)
Add a "#define _ITERATOR_DEBUG_LEVEL 1" on top for VC++.