The-OpenROAD-Project / OpenSTA

OpenSTA engine
GNU General Public License v3.0
399 stars 172 forks source link

reinterpret_cast not allowed #20

Closed just22 closed 5 years ago

just22 commented 5 years ago

Hello,

compiling OpenSTA on OpenBSD (usign either clang 7.0.1 or gcc 4.9.4) I see the following errors:

/usr/ports/pobj/opensta-20190325/OpenSTA-e141c83b2ea1cee8f9414a5733c924e9fb2943e4/app/StaApp_wrap.cc:1087:49: error: reinterpret_cast from 'nullptr_t' to 'char *' is not allowed
    if (Tcl_VarEval(interp,"info commands ", c, reinterpret_cast<char*>(NULL)) == TCL_OK) {
                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/ports/pobj/opensta-20190325/OpenSTA-e141c83b2ea1cee8f9414a5733c924e9fb2943e4/app/StaApp_wrap.cc:1102:45: error: reinterpret_cast from 'nullptr_t' to 'char *' is not allowed
    if (Tcl_VarEval(interp,c," cget -this", reinterpret_cast<char*>(NULL)) != TCL_OK) {
                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

They can be easily solved by using static_cast instead of reinterpret_cast as per the following trivial patch:

Index: etc/SwigCleanup.tcl
--- etc/SwigCleanup.tcl.orig
+++ etc/SwigCleanup.tcl
@@ -93,7 +93,7 @@ proc swig5 { line_var } {
     {, reinterpret_cast<char*>(ptr)} line

   regsub ", *\\\(char *\\\*\\\) NULL" $line \
-    {, reinterpret_cast<char*>(NULL)} line
+    {, static_cast<char*>(NULL)} line

   regsub ", ?\\\(char ?\\\*\\\)(\[^,\\\)\]+)(\[,\\\)\])" $line \
     {, const_cast<char*>(\1)\2} line

but I don't know if that can have any side effects. Could you please double check?

Thanks and regards

-- Alessandro

jjcherry56 commented 5 years ago

That looks like the right fix. I'm impressed you managed to find SwigCleanup.tcl...

On Tuesday, March 26, 2019, Alessandro DE LAURENZIS < notifications@github.com> wrote:

Hello,

compiling OpenSTA on OpenBSD (usign both clang 7.0.1 and gcc 4.9.4) I see the following errors:

/usr/ports/pobj/opensta-20190325/OpenSTA-e141c83b2ea1cee8f9414a5733c924e9fb2943e4/app/StaApp_wrap.cc:1087:49: error: reinterpret_cast from 'nullptr_t' to 'char ' is not allowed if (Tcl_VarEval(interp,"info commands ", c, reinterpret_cast<char>(NULL)) == TCL_OK) { ^~~~~~~~~ /usr/ports/pobj/opensta-20190325/OpenSTA-e141c83b2ea1cee8f9414a5733c924e9fb2943e4/app/StaApp_wrap.cc:1102:45: error: reinterpret_cast from 'nullptr_t' to 'char ' is not allowed if (Tcl_VarEval(interp,c," cget -this", reinterpret_cast<char>(NULL)) != TCL_OK) { ^~~~~~~~~

They can be easily solved by using static_cast instead of reinterpret_cast as per the following trivial patch:

Index: etc/SwigCleanup.tcl --- etc/SwigCleanup.tcl.orig +++ etc/SwigCleanup.tcl @@ -93,7 +93,7 @@ proc swig5 { line_var } { {, reinterpret_cast<char*>(ptr)} line

regsub ", \(char \*\) NULL" $line \

  • {, reinterpret_cast<char*>(NULL)} line
  • {, static_cast<char*>(NULL)} line

    regsub ", ?\(char ?\*\)([^,\)]+)([,\)])" $line \ {, const_cast<char*>(\1)\2} line

but I don't know if that can have any side effects. Could you please double check?

Thanks and regards

-- Alessandro

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/abk-openroad/OpenSTA/issues/20, or mute the thread https://github.com/notifications/unsubscribe-auth/AhI8lXWcxSe2wUFOokp4wR-6PtvR85NYks5vacbzgaJpZM4cKvQE .