Skip to content

[FixedList] Return insertion position for empty ranges - #227

Merged
alexkaratarakis merged 1 commit into
teslamotors:mainfrom
rioyu123:codex/fix-fixed-list-empty-insert
Sep 22, 2026
Merged

alexkaratarakis merged 1 commit into
teslamotors:mainfrom
rioyu123:codex/fix-fixed-list-empty-insert

Conversation

@rioyu123

@rioyu123 rioyu123 commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Inserting an empty range before a non-end position in FixedList returns end() instead of the supplied position. This differs from std::list and can move a caller's insertion cursor to the end even though no elements were inserted. The sequence-container requirements specify that insert(pos, first, last) returns pos when first == last.

Both iterator-category paths now return the original insertion position when no node was inserted. Nonempty insertion under the default checking policy and capacity checks are unchanged. The initializer-list overload dispatches into the same forward-iterator path.

The regression covers begin, middle, and end positions for empty forward ranges, input-iterator ranges, and initializer lists, checking that contents and size remain unchanged. The forward-range and initializer-list cases are checked during constant evaluation; the input-iterator case is checked at runtime.

Testing

Validated on Ubuntu 24.04.3 with GCC 13.3, CMake 4.4.3, Ninja 1.11.1, C++20, and a Debug build using the repository's unmodified top-level CMake project. Dependencies were supplied as isolated CMake CONFIG packages using magic_enum v0.9.7, benchmark v1.9.5, and GoogleTest v1.15.2.

cmake -S . -B build -G Ninja \
  -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH="$DEPS_PREFIX"
cmake --build build \
  --target fixed_list_test fixed_deque_test fixed_doubly_linked_list_test \
  --parallel 4
ctest --test-dir build --build-config Debug \
  -R '^(fixed_list_test|fixed_deque_test|fixed_doubly_linked_list_test)$' \
  --output-on-failure
  • Native CMake build: all three requested targets compiled and linked with the repository's -Werror and -fno-exceptions settings.
  • CTest: 3/3 targets passed (179 GoogleTest cases total): fixed_list_test 93, fixed_deque_test 81, and fixed_doubly_linked_list_test 5.

Prior direct compiler runs (GCC 13.3, GoogleTest v1.15.2, with -Wno-sign-compare) also established:

  • Against unchanged main (d0df5f67e102ba42025ef0ecf761d19a4510a543), the final regression fails to compile at both new static_asserts. An earlier runtime form also demonstrated the input-iterator begin/middle failures.
  • Focused regression under AddressSanitizer and UndefinedBehaviorSanitizer: passed, with no findings.

The native CMake validation used an isolated dependency prefix rather than the repository's CI vcpkg toolchain and covered the three related targets, not the full repository or CI compiler/platform matrix.

@alexkaratarakis
alexkaratarakis force-pushed the codex/fix-fixed-list-empty-insert branch from b1e166e to e858ad2 Compare September 22, 2026 02:56
@alexkaratarakis
alexkaratarakis merged commit e858ad2 into teslamotors:main Sep 22, 2026
5 checks passed
@alexkaratarakis

Copy link
Copy Markdown
Collaborator

Thank you for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants