Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/13879

Change subject: systemc: Change how SC_BIND_PROXY_NIL is initialized.
......................................................................

systemc: Change how SC_BIND_PROXY_NIL is initialized.

The previous implementation dereferenced a null pointer to create a
reference which would then have its address taken in the sc_bind_proxy
constructor. clang says that that uses undefined behavior, so this
change adds a default constructor which initializes the two contained
pointers to null explicitly.

We have to hope systemc code doesn't play around with sc_bind_proxy too
much and doesn't accidentally use this constructor unintentionally, but
it seems like the least bad possible solution which makes clang happy.

Change-Id: Ic59603495fe7a406586a18ce44de979f84089bcd
---
M src/systemc/core/sc_module.cc
M src/systemc/ext/core/sc_module.hh
2 files changed, 4 insertions(+), 3 deletions(-)



diff --git a/src/systemc/core/sc_module.cc b/src/systemc/core/sc_module.cc
index 5d9e3da..fc98aa3 100644
--- a/src/systemc/core/sc_module.cc
+++ b/src/systemc/core/sc_module.cc
@@ -102,6 +102,8 @@
 namespace sc_core
 {

+sc_bind_proxy::sc_bind_proxy() : _interface(nullptr), _port(nullptr) {}
+
 sc_bind_proxy::sc_bind_proxy(sc_interface &_interface) :
     _interface(&_interface), _port(nullptr)
 {}
@@ -110,12 +112,10 @@
     _interface(nullptr), _port(&_port)
 {}

-const sc_bind_proxy SC_BIND_PROXY_NUL(*(sc_port_base *)nullptr);
+const sc_bind_proxy SC_BIND_PROXY_NIL;

 sc_module::~sc_module() { delete _gem5_module; }

-const sc_bind_proxy SC_BIND_PROXY_NIL(*(sc_port_base *)nullptr);
-
 void
 sc_module::operator () (const sc_bind_proxy &p001,
                         const sc_bind_proxy &p002,
diff --git a/src/systemc/ext/core/sc_module.hh b/src/systemc/ext/core/sc_module.hh
index dea728f..0c8bd9f 100644
--- a/src/systemc/ext/core/sc_module.hh
+++ b/src/systemc/ext/core/sc_module.hh
@@ -82,6 +82,7 @@
     sc_port_base *_port;

   public:
+    sc_bind_proxy();
     sc_bind_proxy(sc_interface &_interface);
     sc_bind_proxy(sc_port_base &_port);


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/13879
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: Ic59603495fe7a406586a18ce44de979f84089bcd
Gerrit-Change-Number: 13879
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to