This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]