Skip to content

Commit

Permalink
CarpetX: output invalid array indices in debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
rhaas80 committed Dec 30, 2024
1 parent 98ab37c commit 3ab11f1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions CarpetX/src/driver.cxx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pragma GCC optimize("O0")
#include "driver.hxx"

#include "boundaries.hxx"
Expand Down
10 changes: 10 additions & 0 deletions CarpetX/src/driver.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,21 @@ struct GHExt {
int typesize() const { return _typesize; };

const void *data_at(size_t i) const {
#ifdef CCTK_DEBUG
if (i >= _count) {
CCTK_VERROR("invalid index %zd exceeds %zd", i, _count);
}
#endif
assert(i < _count);
return (char *)_data + i * _typesize;
};

void *data_at(size_t i) {
#ifdef CCTK_DEBUG
if (i >= _count) {
CCTK_VERROR("invalid index %zu exceeds %zu", i, _count);
}
#endif
assert(i < _count);
return (char *)_data + i * _typesize;
};
Expand Down

0 comments on commit 3ab11f1

Please sign in to comment.