Skip to content

Commit

Permalink
Patch sanitizer false positive in gcc 14
Browse files Browse the repository at this point in the history
* ra/ply.hh (ply_fixed): As stated.
  • Loading branch information
lloda committed May 10, 2024
1 parent 0ea55ad commit 17b6677
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

**ra-ra** implements [expression templates](https://en.wikipedia.org/wiki/Expression_templates). This is a C++ technique (pioneered by [Blitz++](http://blitz.sourceforge.net)) to delay the execution of expressions involving array operands, and in this way avoid the unnecessary creation of large temporary array objects.

**ra-ra** is compact (5k loc), easy to extend, and generic. There are no arbitrary type restrictions or limits on rank or argument count.
**ra-ra** is compact (<5k loc), easy to extend, and generic. There are no arbitrary type restrictions or limits on rank or argument count.

In this example ([examples/read-me.cc](examples/read-me.cc)), we create some arrays, do operations on them, and print the result.

Expand Down
5 changes: 3 additions & 2 deletions ra/ply.hh
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ ply_fixed(A && a, Early && early = Nop {})
constexpr rank_t rank = rank_s<A>();
static_assert(0<=rank, "ply_fixed needs static rank");
// inside first. FIXME better heuristic - but first need a way to force row-major
constexpr /* static P2647 gcc13 */ auto order = mp::tuple2array<int, mp::reverse<mp::iota<rank>>>();
constexpr auto order = mp::tuple2array<int, mp::reverse<mp::iota<rank>>>();
if constexpr (0==rank) {
if constexpr (requires {early.def;}) {
return (*a).value_or(early.def);
Expand All @@ -270,9 +270,9 @@ ply_fixed(A && a, Early && early = Nop {})
return;
}
} else {
auto ss0 = a.step(order[0]);
// static keep_step implies all else is static.
if constexpr (RA_STATIC_UNROLL && rank>1 && requires (dim_t st, rank_t z, rank_t j) { A::keep_step(st, z, j); }) {
constexpr auto ss0 = a.step(order[0]);
// find outermost compact dim.
constexpr auto sj = [&order]
{
Expand All @@ -291,6 +291,7 @@ ply_fixed(A && a, Early && early = Nop {})
} else {
#pragma GCC diagnostic push // gcc 12.2 and 13.2 with RA_DO_CHECK=0 and -fno-sanitize=all
#pragma GCC diagnostic warning "-Warray-bounds"
auto ss0 = a.step(order[0]); // gcc 14.1 with RA_DO_CHECK=0 and sanitizer on
// not worth unrolling.
if constexpr (requires {early.def;}) {
return (subply<order, rank-1, 1>(a, a.len(order[0]), ss0, early)).value_or(early.def);
Expand Down

0 comments on commit 17b6677

Please sign in to comment.