systemc: Disable some warnings generating false positives.
authorGabe Black <gabeblack@google.com>
Mon, 25 May 2020 09:02:22 +0000 (02:02 -0700)
committerGabe Black <gabeblack@google.com>
Tue, 26 May 2020 02:24:20 +0000 (02:24 +0000)
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 <power.jg@gmail.com>
Maintainer: Gabe Black <gabeblack@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/systemc/dt/int/SConscript

index 7b97d5faa70937780e851e222fea3dcd2b40e9e7..26bb6aeb3debb825b3769a576f02621ceed93fdf 100644 (file)
 
 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)