Skip to content

Commit 3ab11f1

Browse files
committed
CarpetX: output invalid array indices in debug mode
1 parent 98ab37c commit 3ab11f1

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

CarpetX/src/driver.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#pragma GCC optimize("O0")
12
#include "driver.hxx"
23

34
#include "boundaries.hxx"

CarpetX/src/driver.hxx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,21 @@ struct GHExt {
251251
int typesize() const { return _typesize; };
252252

253253
const void *data_at(size_t i) const {
254+
#ifdef CCTK_DEBUG
255+
if (i >= _count) {
256+
CCTK_VERROR("invalid index %zd exceeds %zd", i, _count);
257+
}
258+
#endif
254259
assert(i < _count);
255260
return (char *)_data + i * _typesize;
256261
};
257262

258263
void *data_at(size_t i) {
264+
#ifdef CCTK_DEBUG
265+
if (i >= _count) {
266+
CCTK_VERROR("invalid index %zu exceeds %zu", i, _count);
267+
}
268+
#endif
259269
assert(i < _count);
260270
return (char *)_data + i * _typesize;
261271
};

0 commit comments

Comments
 (0)