[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: findings on swig-java-bindings

From: Daniel Rall <dlr_at_collab.net>
Date: 2004-03-16 00:12:35 CET

Gustav Munkby wrote:
> Philip Martin wrote:
>
>> Ben Reser <ben@reser.org> writes:
>>
>>
>>>> Gustav and I investigated these warnings via the gcc man page's doc
>>>> for its -fstrict-aliasing flag.
>>
>>
>>
>>> I'd rather figure out how to fix the code than to turn off warnings. If
>>> you want to grab me sometime I'll be happy to work with you to see if we
>>> can't come up with a way to fix the warnings.
>>
>>
>>
>> The code in question is something like
>>
>> svn_txdelta_window_t *arg1 = (svn_txdelta_window_t *) 0 ;
>> if ((SWIG_ConvertPtr(obj0,(void **) &arg1, ...
>>
>> One way to make it warning free would be
>>
>> svn_txdelta_window_t *arg1 = (svn_txdelta_window_t *) 0 ;
>> void *tmp = arg1;
>> if ((SWIG_ConvertPtr(obj0, &tmp, ....
>> arg1 = tmp;
>>
>> I think gcc is warning that an optimizing compiler could assume that
>> SWIG_ConvertPtr will not change arg1.
>>
>> http://www.gnu.org/software/gcc/bugs.html#nonbugs_c
>> http://mail-index.netbsd.org/tech-kern/2003/08/11/0001.html
>>
>
> And as far as I can tell this "could" result in problems, which would be
> very difficult to understand and very hard to find.
>
> Adding -fno-strict-aliasing would be a solution, as it will not disable
> the warnings, but rather disable the optmizations.
>
> The best thing, would probably be to avoid these situations, but since
> the code is generated by swig, it's a little hard for the swig-java
> bindings to do anything about it.
>
> I also get the same warnings if I try to compile the swig-python bindings.
>
> Looking at the Makefile, the swig-perl bindings already has the
> specified flag.

Gustav, something like this, then?

* build/ac-macros/swig.m4
   (SWIG_JAVA_INCLUDES): Include the -fno-strict-aliasing argument to
     gcc to disable the optimization which can generate build warnings.

Index: build/ac-macros/swig.m4
===================================================================
--- build/ac-macros/swig.m4 (revision 9068)
+++ build/ac-macros/swig.m4 (working copy)
@@ -167,7 +167,7 @@
        dnl libsvn_swig_java, we must include the latter's library path.
        dnl ### Eventually reference somewhere under $(DESTDIR)?
        SWIG_JAVA_LINK="$SWIG_PY_LINK -L\$(SWIG_BUILD_DIR)/.libs"
- SWIG_JAVA_INCLUDES="$JNI_INCLUDES"
+ SWIG_JAVA_INCLUDES="-fno-strict-aliasing $JNI_INCLUDES"
      fi

      if test "$PERL" != "none" -a "$SWIG_SUITABLE" = "yes" -a
"$svn_swig_bindings_enable_perl" = "yes"; then

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue Mar 16 00:14:13 2004

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.