Skip to content

Fix empty vector argument array construction#218

Draft
zayenz wants to merge 1 commit into
mainfrom
feature/empty-vector-args
Draft

Fix empty vector argument array construction#218
zayenz wants to merge 1 commit into
mainfrom
feature/empty-vector-args

Conversation

@zayenz

@zayenz zayenz commented Jul 7, 2026

Copy link
Copy Markdown
Member

Summary

  • Fix construction of argument arrays from empty std::vector instances by avoiding &aa[0] when the vector is empty.
  • Add a regression test for empty vector construction of IntArgs, IntVarArgs, and BoolVarArgs.
  • Add a changelog entry thanking @intractabilis.

Fixes #205.

Validation

  • cmake -S . -B /tmp/gecode-empty-vector-args-build -DCMAKE_BUILD_TYPE=Debug -DGECODE_ENABLE_EXAMPLES=OFF -DGECODE_ENABLE_GIST=OFF -DGECODE_ENABLE_QT=OFF
  • cmake --build /tmp/gecode-empty-vector-args-build --target gecode-test -j 8
  • /tmp/gecode-empty-vector-args-build/bin/gecode-test -test Array::Vector::Empty
  • git diff --check

Comment on lines +1560 to +1561
if (n > 0)
heap.copy<T>(a,aa.data(),n);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: aa.data() is fine to call on an empty std::vector (might or might not return nullptr). do we need the if (n > 0) then?

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