bazel: enable additional mem safety compiler checks#10635
Conversation
Signed-off-by: Mike Inouye <mikeinouye@google.com>
There was a problem hiding this comment.
Code Review
This pull request configures several compiler warnings as errors in .bazelrc (such as dangling pointers and array bounds) and updates dbSta.cc to use std::string instead of std::string_view for pin_name. A review comment points out that adding Clang-specific warning options unconditionally to global build options will break GCC builds, and suggests moving them to a compiler-specific configuration block.
| 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" |
There was a problem hiding this comment.
Adding Clang-specific warning options like -Werror=dangling, -Werror=dangling-assignment, -Werror=dangling-gsl, and -Werror=fortify-source unconditionally to the global build options will break builds using the GCC compiler. GCC does not recognize these warning options and will fail the build with a hard error (e.g., error: -Werror=dangling: no option -Wdangling). To maintain compatibility with GCC, consider moving these Clang-specific flags to a compiler-specific configuration block or using Bazel's platform/toolchain-based select mechanism.
Type of Change
Verification
./etc/Build.sh).Related Issues
[Link issues here]