Skip to content

Commit

Permalink
Fix for io segfault under gcc11
Browse files Browse the repository at this point in the history
The segfault only happened with sanitizers off, -O3, and -DRA_DO_CHECK=1, and
only on gcc11; gcc12 and gcc13 work fine, or any -O<3 in gcc11. The error went
away when i removed random combinations of lines in test/io.cc and I couldn't
reduce it. Go figure.

* ra/ply.hh (operator<<): As stated.
  • Loading branch information
lloda committed Mar 22, 2024
1 parent 9e7778a commit 4a1d239
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ra/ply.hh
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,8 @@ operator<<(std::ostream & o, FormatArray<A> const & fa)
static_assert(BAD!=size_s<A>(), "Cannot print undefined size expr.");
auto a = ra::start(fa.a); // [ra35]
auto sha = shape(a);
// the following assert fixes a segfault in gcc11.3 test/io.c with -O3 -DRA_DO_CHECK=1.
assert(every(ra::start(sha)>=0));
if (withshape==fa.fmt.shape || (defaultshape==fa.fmt.shape && size_s(a)==ANY)) {
o << sha << '\n';
}
Expand Down

0 comments on commit 4a1d239

Please sign in to comment.