From 837fcf7c15816c719bf4c5fea707192f497bfec9 Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Wed, 1 Oct 2025 14:52:35 -0700 Subject: [PATCH 1/5] Avoid VLAs --- riscv/bulknormdot.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/riscv/bulknormdot.h b/riscv/bulknormdot.h index 65bcbabf..bbd6bf16 100644 --- a/riscv/bulknormdot.h +++ b/riscv/bulknormdot.h @@ -2,7 +2,7 @@ #define _RISCV_BULKNORMDOT_H #include -#include +#include #include "softfloat.h" struct bulk_norm_out_t { @@ -178,8 +178,8 @@ class ofp8_e4m3 final : public IEEEFloatFormat */ template bulk_norm_out_t bulk_norm_dot_no_mult(const DotConfig cfg, const ValueTypeLHS* a, const ValueTypeRHS* b, const SigProdType* prod_sigs) { - int approx_prod_exp[cfg.n]; - int flushed_prods[cfg.n]; + std::vector approx_prod_exp(cfg.n); + std::vector flushed_prods(cfg.n); bool any_pos_inf = false; bool any_neg_inf = false; @@ -299,27 +299,27 @@ template bul static inline bulk_norm_out_t bulk_norm_dot_bf16(const DotConfig cfg, const bf16_t* a, const bf16_t* b) { // product are extracted so that the no-mult version can be more easily matched against the RTL implementation - uint16_t prod_sigs[cfg.n]; + std::vector prod_sigs(cfg.n); // compute products, normalize to largest exponent, accumulate for (int i = 0; i < cfg.n; i++) { prod_sigs[i] = a[i].sig() * (uint16_t) b[i].sig(); } - return bulk_norm_dot_no_mult(cfg, a, b, prod_sigs); + return bulk_norm_dot_no_mult(cfg, a, b, &prod_sigs[0]); } template bulk_norm_out_t bulk_norm_dot_ofp8(const DotConfig cfg, const L* a, const R* b) { // products are extracted so that the no-mult version can be more easily matched against the RTL implementation - uint16_t prod_sigs[cfg.n]; + std::vector prod_sigs(cfg.n); // compute products, normalize to largest exponent, accumulate for (int i = 0; i < cfg.n; i++) { prod_sigs[i] = a[i].sig() * (uint16_t) b[i].sig(); } - return bulk_norm_dot_no_mult(cfg, a, b, prod_sigs); + return bulk_norm_dot_no_mult(cfg, a, b, &prod_sigs[0]); } #endif From eb90f5aa758b4f0b4ffd9abcec1137ba90c52335 Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Wed, 1 Oct 2025 14:52:43 -0700 Subject: [PATCH 2/5] Add default destructor to suppress warning --- riscv/bulknormdot.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/riscv/bulknormdot.h b/riscv/bulknormdot.h index bbd6bf16..37981ae8 100644 --- a/riscv/bulknormdot.h +++ b/riscv/bulknormdot.h @@ -56,6 +56,9 @@ template class FloatFormat { virtual bool nan() const = 0; virtual bool sigNan() const = 0; virtual bool special() const = 0; + +public: + virtual ~FloatFormat() = default; }; /** Template for an IEEE-754 floating-point format class */ From 9ea67d0ca83975444c2ea1ed6e70cfa3858b34cd Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Wed, 1 Oct 2025 14:52:52 -0700 Subject: [PATCH 3/5] Add UNUSED to suppress warning --- riscv/csrs.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/riscv/csrs.cc b/riscv/csrs.cc index 76f600dd..608c6a63 100644 --- a/riscv/csrs.cc +++ b/riscv/csrs.cc @@ -2141,7 +2141,7 @@ inaccessible_csr_t::inaccessible_csr_t(processor_t* const proc, const reg_t addr csr_t(proc, addr) { } -void inaccessible_csr_t::verify_permissions(insn_t insn, bool write) const { +void inaccessible_csr_t::verify_permissions(insn_t insn, bool UNUSED write) const { if (state->v) throw trap_virtual_instruction(insn.bits()); else From e69c5376a57e6b526e6d934cdda0de40f8288c25 Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Wed, 1 Oct 2025 16:19:59 -0700 Subject: [PATCH 4/5] Suppress warning for unused write() result --- riscv/interactive.cc | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/riscv/interactive.cc b/riscv/interactive.cc index 9afc7185..55406b82 100644 --- a/riscv/interactive.cc +++ b/riscv/interactive.cc @@ -72,6 +72,12 @@ processor_t *sim_t::get_core(const std::string& i) return get_core(p); } +static void do_write(int fd, const void* buf, size_t n) +{ + auto res = write(fd, buf, n); + (void) res; +} + static void clear_str(bool noncanonical, int fd, std::string target_str) { if (noncanonical) @@ -83,7 +89,7 @@ static void clear_str(bool noncanonical, int fd, std::string target_str) clear_motion += ' '; } clear_motion += '\r'; - (void) write(fd, clear_motion.c_str(), clear_motion.size() + 1); + do_write(fd, clear_motion.c_str(), clear_motion.size() + 1); } } @@ -96,7 +102,7 @@ static void send_key(bool noncanonical, int fd, keybuffer_t key_code, const int { key_motion += (char) ((key_code >> (i * BITS_PER_CHAR)) & 0xff); } - (void) write(fd, key_motion.c_str(), len); + do_write(fd, key_motion.c_str(), len); } } @@ -144,7 +150,7 @@ static std::string readline(int fd) cursor_pos--; s.erase(cursor_pos, 1); if (noncanonical) - (void) write(fd, s.c_str(), s.size() + 1); + do_write(fd, s.c_str(), s.size() + 1); // move cursor by left arrow key for (unsigned i = 0; i < s.size() - cursor_pos; i++) { send_key(noncanonical, fd, KEYCODE_LEFT, 3); @@ -176,7 +182,7 @@ static std::string readline(int fd) history_index = std::min(history_commands.size(), history_index + 1); s = history_commands[history_commands.size() - history_index]; if (noncanonical) - (void) write(fd, s.c_str(), s.size() + 1); + do_write(fd, s.c_str(), s.size() + 1); cursor_pos = s.size(); } key_buffer = 0; @@ -192,7 +198,7 @@ static std::string readline(int fd) s = history_commands[history_commands.size() - history_index]; } if (noncanonical) - (void) write(fd, s.c_str(), s.size() + 1); + do_write(fd, s.c_str(), s.size() + 1); cursor_pos = s.size(); } key_buffer = 0; @@ -221,7 +227,7 @@ static std::string readline(int fd) break; case KEYCODE_ENTER: if (noncanonical) - (void) write(fd, &ch, 1); + do_write(fd, &ch, 1); if (s.size() > initial_s_len && (history_commands.size() == 0 || s != history_commands[history_commands.size() - 1])) { history_commands.push_back(s); } @@ -236,7 +242,7 @@ static std::string readline(int fd) s.insert(cursor_pos, 1, ch); cursor_pos++; if (noncanonical) - (void) write(fd, s.c_str(), s.size() + 1); + do_write(fd, s.c_str(), s.size() + 1); // send left arrow key to move cursor for (unsigned i = 0; i < s.size() - cursor_pos; i++) { send_key(noncanonical, fd, KEYCODE_LEFT, 3); From ffcc3e69a7fb30aa1d71dcd564eb4b79f6f5deb5 Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Wed, 1 Oct 2025 14:53:01 -0700 Subject: [PATCH 5/5] Actually use -Werror in CI again --- ci-tests/build-spike | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ci-tests/build-spike b/ci-tests/build-spike index 0a1b3159..2ca48956 100755 --- a/ci-tests/build-spike +++ b/ci-tests/build-spike @@ -8,7 +8,9 @@ rm -rf build mkdir build cd build mkdir install -CXXFLAGS="-Wnon-virtual-dtor" CFLAGS="-Werror -Wall -Wextra -Wvla" $DIR/../configure --prefix=`pwd`/install +CFLAGS="-Werror -Wall -Wextra -Wvla" +CXXFLAGS="-Wnon-virtual-dtor $CFLAGS" +CXXFLAGS="$CXXFLAGS" CFLAGS="$CFLAGS" $DIR/../configure --prefix=`pwd`/install make -j"$(nproc 2> /dev/null || sysctl -n hw.ncpu)" make check make install install-hdrs-list.h