octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Octave 2.9.6 available for ftp


From: John W. Eaton
Subject: Re: Octave 2.9.6 available for ftp
Date: Mon, 12 Jun 2006 11:54:01 -0400

On  9-Jun-2006, Bill Denney wrote:

| On Fri, 9 Jun 2006, John W. Eaton wrote:
| 
| > On  9-Jun-2006, Tom Holroyd (NIH/NIMH) [E] wrote:
| >
| > | $ g++ -c  -fPIC -I. -I.. -I../liboctave -I../src -I../libcruft/misc  
-DHAVE_CONFIG_H -mieee-fp -Wall -W -Wshadow -Wold-style-cast -g -O2 
dynamic-ld.cc -o pic/dynamic-ld.o
| > | dynamic-ld.cc: In member function `bool 
octave_dynamic_loader::do_load(const
| > |    std::string&, const std::string&)':
| > | dynamic-ld.cc:268: ISO C++ forbids casting between pointer-to-function and
| > |    pointer-to-object
| > | $ g++ -v
| > | Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/specs
| > | Configured with: ../configure --prefix=/usr --mandir=/usr/share/man 
--infodir=/usr/share/info --enable-shared --enable-threads=posix 
--disable-checking --with-system-zlib --enable-__cxa_atexit 
--host=i386-redhat-linux
| > | Thread model: posix
| > | gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-54)
| >
| > GCC 3.2 is old and this is a bug in GCC, not Octave.
| >
| > But, if you want to stick with GCC 3.2 you can work around the bug by
| > using a C-style cast instead of a C++ reinterpret_cast.
| 
| I appear to be getting a similar error in cygwin:
| 
| g++ -c  -I. -I.. -I../liboctave -I../src -I../libcruft/misc  -DHAVE_CONFIG_H 
-mieee-fp -Wall -W -Wshadow -Wold-style-cast -g -O2 dynamic-ld.cc -o 
dynamic-ld.o
| dynamic-ld.cc: In member function `bool octave_dynamic_loader::do_load(const
|     std::string&, const std::string&)':
| dynamic-ld.cc:268: error: ISO C++ forbids casting between pointer-to-function
|     and pointer-to-object
| make[2]: *** [dynamic-ld.o] Error 1
| make[2]: Leaving directory `/tmp/octave-2.9.6/src'
| make[1]: *** [src] Error 2
| make[1]: Leaving directory `/tmp/octave-2.9.6'
| make: *** [all] Error 2

OK, since not working around this GCC bug will probably generate a lot
of useless noise on the lists, here is a patch for changes I just
checked in.

jwe


ChangeLog:

2006-06-12  John W. Eaton  <address@hidden>

        * aclocal.m4 (OCTAVE_CXX_BROKEN_REINTERPRET_CAST): New macro.
        * configure.in: Use it.
        * AH_BOTTOM: Conditionally define FCN_PTR_CAST here.

src/ChangeLog:

2006-06-12  John W. Eaton  <address@hidden>

        * unwind-prot.h (unwind_protect_fptr): New macro.
        * load-path.cc (load_path::do_set): Use it instead of
        unwind_protect_ptr when protecting add_hook function pointer.
        * dynamic-ld.cc (octave_dynamic_loader::do_load): Use FCN_PTR_CAST
        here instead of reinterpret_cast.


Index: aclocal.m4
===================================================================
RCS file: /cvs/octave/aclocal.m4,v
retrieving revision 1.95
diff -u -r1.95 aclocal.m4
--- aclocal.m4  7 Jun 2006 15:38:58 -0000       1.95
+++ aclocal.m4  12 Jun 2006 15:51:55 -0000
@@ -709,6 +709,27 @@
   AC_DEFINE_UNQUOTED(CXX_ABI, $octave_cv_cxx_abi, [Define to the C++ ABI your 
compiler uses.])
 ])
 dnl
+dnl Check to see if C++ reintrepret cast works for function pointers.
+dnl
+dnl OCTAVE_CXX_BROKEN_REINTERPRET_CAST
+dnl
+AC_DEFUN(OCTAVE_CXX_BROKEN_REINTERPRET_CAST, [
+  AC_REQUIRE([AC_PROG_CXX])
+  AC_LANG_PUSH(C++)
+  AC_CACHE_CHECK([for broken C++ reinterpret_cast],
+    octave_cv_cxx_broken_reinterpret_cast, [
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <cmath>]], [[
+      typedef double (*fptr) (double);
+      fptr psin = sin;
+      void *vptr = reinterpret_cast<void *> (psin);
+      psin = reinterpret_cast<fptr> (vptr);]])],
+      octave_cv_cxx_broken_reinterpret_cast=no,
+      octave_cv_cxx_broken_reinterpret_cast=yes)])
+  if test $octave_cv_cxx_broken_reinterpret_cast = yes ; then
+    AC_DEFINE(CXX_BROKEN_REINTERPRET_CAST, 1, [Define if C++ reinterpret_cast 
fails for function pointers.])
+fi
+  AC_LANG_POP(C++)])
+dnl
 dnl Determine if mkdir accepts only one argument instead dnl of the usual 2.
 dnl
 AC_DEFUN(OCTAVE_MKDIR_TAKES_ONE_ARG,
Index: configure.in
===================================================================
RCS file: /cvs/octave/configure.in,v
retrieving revision 1.513
diff -u -r1.513 configure.in
--- configure.in        7 Jun 2006 15:38:58 -0000       1.513
+++ configure.in        12 Jun 2006 15:51:55 -0000
@@ -207,6 +207,7 @@
 
 OCTAVE_CXX_NEW_FRIEND_TEMPLATE_DECL
 OCTAVE_CXX_ISO_COMPLIANT_LIBRARY
+OCTAVE_CXX_BROKEN_REINTERPRET_CAST
 
 # Determine the ABI used the C++ compiler, needed by the dynamic loading
 # code. Currently supported ABIs are GNU v2, GNU v3 and Sun Workshop.
@@ -1632,6 +1633,12 @@
 
 #define X_CAST(T, E) (T) (E)
 
+#if defined (CXX_BROKEN_REINTERPRET_CAST)
+#define FCN_PTR_CAST(T, E) (T) (E)
+#else
+#define FCN_PTR_CAST(T, E) reinterpret_cast<T> (E)
+#endif
+
 #if defined(HAVE_F2C) && !defined(F77_FUNC)
 #  define F77_FUNC(x,X) x ## _
 #  define F77_FUNC_(x,X) x ## __
Index: src/dynamic-ld.cc
===================================================================
RCS file: /cvs/octave/src/dynamic-ld.cc,v
retrieving revision 1.73
diff -u -r1.73 dynamic-ld.cc
--- src/dynamic-ld.cc   2 May 2006 19:40:20 -0000       1.73
+++ src/dynamic-ld.cc   12 Jun 2006 15:51:59 -0000
@@ -265,7 +265,7 @@
   if (function)
     {
       octave_dld_fcn_installer f
-       = reinterpret_cast<octave_dld_fcn_installer> (function);
+       = FCN_PTR_CAST (octave_dld_fcn_installer, function);
 
       retval = f (oct_file);
 
Index: src/load-path.cc
===================================================================
RCS file: /cvs/octave/src/load-path.cc,v
retrieving revision 1.1
diff -u -r1.1 load-path.cc
--- src/load-path.cc    26 May 2006 21:42:22 -0000      1.1
+++ src/load-path.cc    12 Jun 2006 15:51:59 -0000
@@ -424,7 +424,7 @@
 
   // Temporarily disable add hook.
 
-  unwind_protect_ptr (add_hook);
+  unwind_protect_fptr (add_hook);
 
   add_hook = 0;
 
Index: src/unwind-prot.h
===================================================================
RCS file: /cvs/octave/src/unwind-prot.h,v
retrieving revision 1.28
diff -u -r1.28 unwind-prot.h
--- src/unwind-prot.h   14 Apr 2006 04:01:40 -0000      1.28
+++ src/unwind-prot.h   12 Jun 2006 15:51:59 -0000
@@ -125,6 +125,10 @@
   unwind_protect::save_ptr (reinterpret_cast<void **> (&(p)), \
                             reinterpret_cast<void *> (p))
 
+#define unwind_protect_fptr(p) \
+  unwind_protect::save_ptr (reinterpret_cast<void **> (&(p)), \
+                            FCN_PTR_CAST (void *, p))
+
 #define unwind_protect_const_ptr(p) \
   unwind_protect::save_ptr (const_cast<void **> (reinterpret_cast<const void 
**> (&(p))), \
                             const_cast<void *> (reinterpret_cast<const void *> 
(p)))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]