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