public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/32697]  New: O2 optimizes away assignment
@ 2007-07-09 13:20 Dries dot Decock at excentis dot com
  2007-07-09 13:35 ` [Bug c++/32697] " schwab at suse dot de
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Dries dot Decock at excentis dot com @ 2007-07-09 13:20 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-07-09 14:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-09 13:20 [Bug c++/32697] New: O2 optimizes away assignment Dries dot Decock at excentis dot com
2007-07-09 13:35 ` [Bug c++/32697] " schwab at suse dot de
2007-07-09 13:56 ` sorenj at us dot ibm dot com
2007-07-09 14:07 ` Dries dot Decock at excentis dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).