From f3393e4570560948d447f48983dd6e4e6457ff15 Mon Sep 17 00:00:00 2001 From: Mike Inouye Date: Wed, 10 Jun 2026 22:52:35 +0000 Subject: [PATCH] bazel: enable additional mem safety compiler checks Signed-off-by: Mike Inouye --- .bazelrc | 11 ++++++++++- src/dbSta/src/dbSta.cc | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.bazelrc b/.bazelrc index 5b1b778aa8d..d9368eea841 100644 --- a/.bazelrc +++ b/.bazelrc @@ -50,6 +50,16 @@ build --cxxopt=-fexceptions --host_cxxopt=-fexceptions build --copt "-Wall" --host_copt "-Wall" build --copt "-Wextra" --host_copt "-Wextra" +# Treat specific warnings as errors +build --copt "-Werror=array-bounds" --host_copt "-Werror=array-bounds" +build --copt "-Werror=dangling" --host_copt "-Werror=dangling" +build --copt "-Werror=dangling-assignment" --host_copt "-Werror=dangling-assignment" +build --copt "-Werror=dangling-assignment-gsl" --host_copt "-Werror=dangling-assignment-gsl" +build --copt "-Werror=dangling-field" --host_copt "-Werror=dangling-field" +build --copt "-Werror=dangling-gsl" --host_copt "-Werror=dangling-gsl" +build --copt "-Werror=fortify-source" --host_copt "-Werror=fortify-source" +build --copt "-Werror=return-stack-address" --host_copt "-Werror=return-stack-address" + # ... and disable the warnings we're not interested in. build --copt "-Wno-sign-compare" --host_copt "-Wno-sign-compare" build --copt "-Wno-unused-parameter" --host_copt "-Wno-unused-parameter" @@ -73,7 +83,6 @@ build --copt "-Wno-cast-function-type-mismatch" --host_copt "-Wno-cast-function build --copt "-Wno-unused-but-set-variable" --host_copt "-Wno-unused-but-set-variable" build --cxxopt "-Wno-deprecated-copy" --host_cxxopt "-Wno-deprecated-copy" build --cxxopt "-Wno-deprecated-copy-with-user-provided-copy" --host_cxxopt "-Wno-deprecated-copy-with-user-provided-copy" -build --cxxopt "-Wno-dangling" --host_cxxopt "-Wno-dangling" # For 3rd party code: Disable warnings entirely. # They are not actionable and just create noise. diff --git a/src/dbSta/src/dbSta.cc b/src/dbSta/src/dbSta.cc index 9dc76a7a21e..2d98c3b2ab3 100644 --- a/src/dbSta/src/dbSta.cc +++ b/src/dbSta/src/dbSta.cc @@ -1602,7 +1602,7 @@ void dbSta::dumpModInstGraphConnections(const char* mod_inst_name, bool is_external = false; if (from_pin) { - std::string_view pin_name = network()->name(from_pin); + std::string pin_name = network()->name(from_pin); std::string mod_prefix = db_mod_inst->getName(); mod_prefix += "/"; // e.g., "_202_/" if (!pin_name.starts_with(mod_prefix)) {