[Bug c++/32697] New: O2 optimizes away assignment
Hi, I'm using SWIG to combine Java and C++ code. At some point, SWIG generates a method like this : 1SWIGEXPORT jlong JNICALL Java_com_excentis_products_X_XUpcast(JNIEnv *jenv, jclass jcls, jlong jarg1) { jlong baseptr = 0; (void)jenv; (void)jcls; *(Flow **)&baseptr = *(TcpFlow **)&jarg1; return baseptr; } The problem is that the assignment is not executed and the return value is always zero, when using -O2 optimization. When I disable O2, or add a debug statement, the value is ok. I don't like the generated code, but it should work fine. -- Summary: O2 optimizes away assignment Product: gcc Version: 4.1.2 Status: UNCONFIRMED Severity: major Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: Dries dot Decock at excentis dot com GCC build triplet: i686-pc-linux GCC host triplet: i686-pc-linux GCC target triplet: i686-pc-linux i686-mingw32 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32697
[Bug c++/32700] New: O2 optimizes away assignment
Hi, I'm using SWIG to combine Java and C++ code. At some point, SWIG generates a method like this : 1SWIGEXPORT jlong JNICALL Java_com_excentis_products_X_XUpcast(JNIEnv *jenv, jclass jcls, jlong jarg1) { jlong baseptr = 0; (void)jenv; (void)jcls; *(Flow **)&baseptr = *(TcpFlow **)&jarg1; return baseptr; } The problem is that the assignment is not executed and the return value is always zero, when using -O2 optimization. When I disable O2, or add a debug statement, the value is ok. I don't like the generated code, but it should work fine. -- Summary: O2 optimizes away assignment Product: gcc Version: 4.1.2 Status: UNCONFIRMED Severity: major Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: Dries dot Decock at excentis dot com GCC build triplet: i686-pc-linux GCC host triplet: i686-pc-linux GCC target triplet: i686-pc-linux i686-mingw32 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32700
[Bug c++/32700] O2 optimizes away assignment
--- Comment #1 from Dries dot Decock at excentis dot com 2007-07-09 14:06 --- Sorry, dup -- Dries dot Decock at excentis dot com changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution||INVALID http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32700
[Bug c++/32697] O2 optimizes away assignment
--- Comment #3 from Dries dot Decock at excentis dot com 2007-07-09 14:07 --- Thanks for the reply. I will use the -fno-strict-aliasing for now, and hope that the SWIG maintainers will fix this problem in the near future. Thanks again. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32697