Skip to content

Commit 1d67cff

Browse files
committed
fix: extend gcc -Wnonnull hint into check_index
The earlier hint in impl_ref() only cut the warning chain at the DistArray::begin/end call sites. find/set/owner/is_local/is_zero etc. call check_index(i) and then dereference pimpl_ directly; gcc-14 doesn't propagate the non-null guarantee out of impl_ref() across check_index's return boundary. Add the same TILEDARRAY_UNREACHABLE hint at the bottom of each check_index overload — check_index calls impl_ref() (which asserts pimpl_) and check_local_index then delegates to check_index, so this single point covers every public method that pre-validates via check_index before bare pimpl_-> deref.
1 parent 0c5947f commit 1d67cff

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/TiledArray/dist_array.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1628,6 +1628,10 @@ class DistArray : public madness::archive::ParallelSerializableObject {
16281628
TA_ASSERT(
16291629
impl_ref().tiles_range().includes_ordinal(ord) &&
16301630
"The ordinal index used to access an array tile is out of range.");
1631+
// After check_index returns, pimpl_ is non-null (impl_ref() asserts).
1632+
// Hint to gcc -Wnonnull so direct `pimpl_->...` uses in the caller
1633+
// don't trip on a propagated null `this` across inlining boundaries.
1634+
if (!pimpl_) TILEDARRAY_UNREACHABLE;
16311635
}
16321636

16331637
template <typename Index>
@@ -1636,6 +1640,7 @@ class DistArray : public madness::archive::ParallelSerializableObject {
16361640
TA_ASSERT(
16371641
impl_ref().tiles_range().includes(i) &&
16381642
"The coordinate index used to access an array tile is out of range.");
1643+
if (!pimpl_) TILEDARRAY_UNREACHABLE;
16391644
}
16401645

16411646
template <typename Index1,

0 commit comments

Comments
 (0)