Skip to content

Initialize the operand of the xfixed buffer_adaptor test - #2961

Open
gouarin wants to merge 1 commit into
xtensor-stack:masterfrom
gouarin:fix-xfixed-test-uninit
Open

gouarin wants to merge 1 commit into
xtensor-stack:masterfrom
gouarin:fix-xfixed-test-uninit

Conversation

@gouarin

@gouarin gouarin commented Oct 29, 2026

Copy link
Copy Markdown
Member

Checklist

  • The title and commit message(s) are descriptive.
  • Small commits made to fix your PR have been squashed to avoid history pollution.
  • Tests have been added for new features or bug fixes.
  • API of new functions and classes are documented (no public API changes).

Description

xtensor_fixed.buffer_adaptor multiplied an adapted row by a default-constructed xtensor_fixed:

xtensor_fixed<double, xshape<3>> a;  // elements not initialized, like std::array
xtensor<double, 2> b = zeros<double>({3, 3});
auto c = adapt(&b(0, 0), xshape<3>());
c *= a;                              // reads indeterminate values, checks nothing

GCC 13 at -O3 reports this read as -Wmaybe-uninitialized in the multiplies operator, and in xcontainer::load_simd with XTENSOR_USE_XSIMD. The warning is right: the bug is in the test, not in the library.

The operand is now initialized, the buffer starts at ones so the product shows, and the test checks the result. test_xfixed compiles without these warnings with GCC 13 -O3, with and without xsimd.

The xtensor_fixed.buffer_adaptor test multiplied an adapted row by a
default constructed xtensor_fixed. Like std::array, xtensor_fixed does
not initialize its elements, so the test read indeterminate values and
checked nothing. GCC 13 at -O3 reports the read as
-Wmaybe-uninitialized in the multiplies operator, and in
xcontainer::load_simd when XTENSOR_USE_XSIMD is defined.

The operand is now initialized, the buffer starts at ones so the
product is visible, and the test checks the result.
@codspeed

codspeed Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

1 warning

⚠️ Unable to measure the execution of 1 benchmark

This benchmark measured no execution time, so its result is not comparable and counts as unchanged. This usually happens when the compiler removes the code under test.

Prevent compiler optimizations

See affected benchmarks

✅ 255 untouched benchmarks


Comparing gouarin:fix-xfixed-test-uninit (93fd3ac) with master (57f3d07)

Open in CodSpeed

This branch has not been deployed

No deployments
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.

1 participant