[Bug c++/33607] New: -O2 optimisation causes null pointer exception at runtime when calling g++ from java using jni
mattias dot ellert at tsl dot uu dot se
gcc-bugzilla@gcc.gnu.org
Mon Oct 1 08:40:00 GMT 2007
I have experienced a null pointer exception when calling g++ from java (using
swig generated bindings).
I have made a reduced test case that exhibits the same behaviour which
is attached to this report. If I run this on Fedora Core 6 I get:
[ellert@ellert ~]$ tar -z -x -f java-test.tar.gz
[ellert@ellert ~]$ cd java-test
[ellert@ellert java-test]$ ./test.sh
Exception in thread "main" java.lang.NullPointerException
at test.mytest.Status.getKind(Status.java:45)
at test.main(test.java:9)
Running on RHEL 4 works:
[ellert@bestla ~]$ tar -z -x -f java-test.tar.gz
[ellert@bestla ~]$ cd java-test
[ellert@bestla java-test]$ ./test.sh
OK
If I remove the -O2 optimisation flag from the compilation of the C++
code generated by swig as part of the Java binding it works also on FC6:
[ellert@ellert java-test]$ OPT=no ./test.sh
OK
My RHEL 4 installation has g++ 3.4.6-8, my FC6 installation has g++
4.1.2-13.
The same behaviour has been seen using Debian/Etch g++ 4.1.1-21.
Since removing the -O2 flag makes the code work I suspect this to be an
optimisation problem in g++. Since it works with the -O2 flag with the older
g++ in RHEL4 this would be a regression.
--
Summary: -O2 optimisation causes null pointer exception at
runtime when calling g++ from java using jni
Product: gcc
Version: 4.1.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: mattias dot ellert at tsl dot uu dot se
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33607
More information about the Gcc-bugs
mailing list