From 7cea164392d53b186842cc00663e1577fb778db1 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Mon, 25 May 2020 02:02:22 -0700 Subject: [PATCH] systemc: Disable some warnings generating false positives. These false positives break the build. The error is below, and is bogus as best I can tell. The constructor for the sc_unsigned and sc_signed types, defined with some macro goop in sc_nbcommon.inc, have a call to vec_copy_and_zero to copy over some data and zero the data that isn't copied. That only happens if the source is smaller than the destination. Then in vec_copy_and_zero, it calls vec_zero to set the last elements to zero. Because of the check back at the constructor, only values that exist should ever be set. Also, in gem5, SC_MAX_NBITS is not set, so the definition of the array it's bounds checking is declared right near where it's used and is sized based on the variable being passed into vec_copy_and_zero. In file included from build/ARM/systemc/ext/dt/bit/../int/../fx/sc_fxdefs.hh:52, from build/ARM/systemc/ext/dt/bit/../int/sc_length_param.hh:63, from build/ARM/systemc/ext/dt/bit/sc_bv_base.hh:56, from build/ARM/systemc/dt/int/sc_unsigned.cc:83: In function 'void sc_dt::vec_zero(int, int, sc_dt::sc_digit*)', inlined from 'void sc_dt::vec_copy_and_zero(int, sc_dt::sc_digit*, int, const sc_digit*)' at build/ARM/systemc/ext/dt/bit/../int/../fx/../int/sc_nbutils.hh:407:13, inlined from 'sc_dt::sc_unsigned::sc_unsigned(sc_dt::small_type, int, int, sc_dt::sc_digit*, bool)' at build/ARM/systemc/dt/int/sc_nbcommon.inc:2285:26: build/ARM/systemc/ext/dt/bit/../int/../fx/../int/sc_nbutils.hh:379:14: error: 'void* __builtin_memset(void*, int, long unsigned int)' offset [12, 15] is out of the bounds [0, 12] [-Werror=array-bounds] 379 | u[i] = 0; | Change-Id: Ica721178b24de56dbeabf4af7d3422dea6336a23 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/29432 Reviewed-by: Jason Lowe-Power Maintainer: Gabe Black Tested-by: kokoro --- src/systemc/dt/int/SConscript | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/systemc/dt/int/SConscript b/src/systemc/dt/int/SConscript index 7b97d5faa..26bb6aeb3 100644 --- a/src/systemc/dt/int/SConscript +++ b/src/systemc/dt/int/SConscript @@ -25,13 +25,22 @@ Import('*') +from m5.util import compareVersions + if env['USE_SYSTEMC']: + if main['GCC'] and compareVersions(main['GCC_VERSION'], '10.1') >= 0: + disable_false_positives = { + "CCFLAGS": [ "-Wno-array-bounds", + "-Wno-stringop-overflow" ] + } + else: + disable_false_positives = {} Source('messages.cc') Source('sc_int_base.cc') Source('sc_int_mask.cc') Source('sc_length_param.cc') Source('sc_nbexterns.cc') Source('sc_nbutils.cc') - Source('sc_signed.cc') + Source('sc_signed.cc', append=disable_false_positives) Source('sc_uint_base.cc') - Source('sc_unsigned.cc') + Source('sc_unsigned.cc', append=disable_false_positives) -- 2.30.2