Another buggy complex workaround
petter.urkedal@telia.com
petter.urkedal@telia.com
Sat Apr 1 00:00:00 GMT 2000
The library can not be used for complex math at the time, since
gcc gives an ICE under some circumstances when it has to synthesize
the copy-ctors of the complex<float>, complex<double> and
complex<long double> classes. (The library compiles fine, though).
The fix is simply to define these constructors. Attached is a patch
similar to the workaround for __complex__ float done by Mumit Khan
1999-11-21. Does this fix the __complex__ float bug, as well?
2000-02-05 Petter Urkedal <petter@matfys.lth.se>
* acinclude.m4: New GLIBCPP_CHECK_COMPLEX_SUPPORT macro. Based
on the 1999-11-21 entries by Mumit Khan.
* configure.in: Use.
* acconfig.h: New _GLIBCPP_BUGGY_COMPLEX macro.
* bits/std_complex.h: Use.
-----TEST CASE----------------------
#include <complex>
int main() {
std::complex<float> a, b, c;
a = b*c;
return 0;
}
-----COMPILER OUTPUT [line numbers are wrong]----------------
/usr/local/newgcc/include/g++-v3/bits/std_complex.h: In function
`complex<_Tp> operator* (const complex<_Tp> &, const complex<_Tp> &)
[with _Tp = float]':
ice.cc:5: instantiated from here
/usr/local/newgcc/include/g++-v3/bits/std_complex.h:851: Internal
compiler error.
/usr/local/newgcc/include/g++-v3/bits/std_complex.h:851: Please submit a
full bug report.
/usr/local/newgcc/include/g++-v3/bits/std_complex.h:851: See
<URL: http://www.gnu.org/software/gcc/faq.html#bugreport > for
instructions.
-----COMPILER (compiled from CVS sources)---------------------
Reading specs from
/usr/local/newgcc/lib/gcc-lib/i686-pc-linux-gnu/2.96/specs
gcc version 2.96 20000131 (experimental)
-----ARCHITECTURE-------------------------------------------------
Linux mundane 2.2.13 #1 Mon Nov 8 15:37:25 CET 1999 i686 unknown
--------------------------------------------------------------------
Index: acinclude.m4
===================================================================
RCS file: /cvs/libstdc++/libstdc++/acinclude.m4,v
retrieving revision 1.4
diff -c -r1.4 acinclude.m4
*** acinclude.m4 2000/01/14 19:55:25 1.4
--- acinclude.m4 2000/02/05 19:08:18
***************
*** 44,49 ****
--- 44,89 ----
dnl
+ dnl Check to see if this version of GNU C++ is afflicted by bugs in
+ dnl __complex__ support.
+ dnl
+ dnl Define _GLIBCPP_BUGGY_COMPLEX if buggy.
+ dnl
+ dnl GLIBCPP_CHECK_FLOAT_COMPLEX_SUPPORT
+ AC_DEFUN(GLIBCPP_CHECK_COMPLEX_SUPPORT, [
+ AC_REQUIRE([AC_PROG_CXX])
+ AC_MSG_CHECKING([for GNU C++ __complex__ support])
+ AC_CACHE_VAL(glibcpp_cv_complex, [
+ AC_LANG_SAVE
+ AC_LANG_CPLUSPLUS
+ rm -f conftest.h
+ cat > conftest.h <<EOB
+ //
+ // Check for buggy __complex__ that will cause ICE in gcc-2.95.x when
+ // using the library, unless we define the default copy ctor in the
+ // specializations of complex<>.
+ //
+ struct dcomplex { __complex__ double x; };
+ dcomplex f(const dcomplex& x) { return dcomplex(x); }
+ int main() {
+ dcomplex x;
+ f(x);
+ }
+ EOB
+ AC_TRY_COMPILE([#include "conftest.h"], ,
+ glibcpp_cv_complex=ok,
+ glibcpp_cv_complex=buggy
+ )
+ AC_LANG_RESTORE
+ ])
+ AC_MSG_RESULT($glibcpp_cv_complex)
+ if test $glibcpp_cv_complex = buggy; then
+ AC_DEFINE(_GLIBCPP_BUGGY_COMPLEX)
+ fi
+ ])
+
+
+ dnl
dnl Check for certain special build configurations.
dnl
dnl GLIBCPP_ENABLE_DEBUG
Index: configure.in
===================================================================
RCS file: /cvs/libstdc++/libstdc++/configure.in,v
retrieving revision 1.46
diff -c -r1.46 configure.in
*** configure.in 2000/02/03 06:35:20 1.46
--- configure.in 2000/02/05 19:08:19
***************
*** 322,327 ****
--- 322,328 ----
AC_LC_MESSAGES
GLIBCPP_CHECK_FLOAT_COMPLEX_SUPPORT
+ GLIBCPP_CHECK_COMPLEX_SUPPORT
# Sanity checking & User-visible messages.
# (Sanity checks down here, otherwise they get scrolled off before
Index: acconfig.h
===================================================================
RCS file: /cvs/libstdc++/libstdc++/acconfig.h,v
retrieving revision 1.12
diff -c -r1.12 acconfig.h
*** acconfig.h 1999/12/21 16:53:14 1.12
--- acconfig.h 2000/02/05 19:08:20
***************
*** 46,51 ****
--- 46,54 ----
// Define if GCC support for __complex__ float is buggy.
#undef _GLIBCPP_BUGGY_FLOAT_COMPLEX
+ // Define if GCC support for __complex__ is buggy.
+ #undef _GLIBCPP_BUGGY_COMPLEX
+
// @BOTTOM@
//
// Systems that have certain non-standard functions prefixed with an
Index: bits/std_complex.h
===================================================================
RCS file: /cvs/libstdc++/libstdc++/bits/std_complex.h,v
retrieving revision 1.12
diff -c -r1.12 std_complex.h
*** std_complex.h 1999/12/15 04:52:18 1.12
--- std_complex.h 2000/02/05 19:08:22
***************
*** 140,145 ****
--- 140,148 ----
typedef float value_type;
complex(float = 0.0f, float = 0.0f);
+ #ifdef _GLIBCPP_BUGGY_COMPLEX
+ complex(const complex& __z) : _M_value(__z._M_value) {}
+ #endif
explicit complex(const complex<double>&);
explicit complex(const complex<long double>&);
***************
*** 216,221 ****
--- 219,227 ----
typedef double value_type;
complex(double =0.0, double =0.0);
+ #ifdef _GLIBCPP_BUGGY_COMPLEX
+ complex(const complex& __z) : _M_value(__z._M_value) {}
+ #endif
complex(const complex<float>&);
explicit complex(const complex<long double>&);
***************
*** 291,296 ****
--- 297,305 ----
typedef long double value_type;
complex(long double = 0.0L, long double = 0.0L);
+ #ifdef _GLIBCPP_BUGGY_COMPLEX
+ complex(const complex& __z) : _M_value(__z._M_value) {}
+ #endif
complex(const complex<float>&);
complex(const complex<double>&);
More information about the Libstdc++
mailing list