This is the mail archive of the libstdc++@sourceware.cygnus.com mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Two small patches


While compiling the 19990604 cvs sources with
-fnew-abi -fhonor-std I came across two small problems:

a) The compilation fails in bits/std_cmath.h as the compiler
cannot call ::modf(__x, __y) with __y being a float.
The prototype of ::modf is 'double modf(double x, double *iptr)'
So you want also not define 'float modf(float,float)'
but 'float modf(float,float*)'.

Here is my proposal:

Index: bits/std_cmath.h
===================================================================
RCS file: /cvs/libstdc++/libstdc++/bits/std_cmath.h,v
retrieving revision 1.8
diff -c -3 -r1.8 std_cmath.h
*** std_cmath.h	1999/06/02 18:41:57	1.8
--- std_cmath.h	1999/06/05 11:27:51
***************
*** 95,101 ****
      log10(float __x) { return ::log10(__x); }
  
      inline float
!     modf(float __x, float __y) { return ::modf(__x, __y); }
  
      inline float
      pow(float __x, float __y) { return ::pow(__x, __y); }
--- 95,107 ----
      log10(float __x) { return ::log10(__x); }
  
      inline float
!     modf(float __x, float* __y) 
!     {
!        double __tmp;
!        double __ret = ::modf(__x, &__tmp);
!        *__y = __tmp;
!        return __ret; 
!     }
  
      inline float
      pow(float __x, float __y) { return ::pow(__x, __y); }


if you realy need a testcase for this take (-fhonor-std):
--------------
#include <cassert>
#include <cmath>

int main()
{
	double a=34.573;
	double b;
	float aa=a;
	float bb;

	double c=modf(a,&b); //std::modf(double,double*) is not here jet
	float cc=std::modf(aa,&bb);
	assert(fabs(c-cc)<0.0001); //std::fabs(double) also not
	assert(fabs(b-bb)<0.0001);
}
--------------

b) Linking with the new library gives two "undefined reference"
errors: __out_of_range(char const *) 
and __length_error(char const *).

The solution is to put the declaration of 
  extern void __out_of_range (const char *__str);
  extern void __length_error (const char *__str);
in bits/basic_string.h into namespace std 
as it is done in bits/utility.h:

Index: bits/basic_string.h
===================================================================
RCS file: /cvs/libstdc++/libstdc++/bits/basic_string.h,v
retrieving revision 1.31
diff -c -3 -r1.31 basic_string.h
*** basic_string.h	1999/05/21 15:34:20	1.31
--- basic_string.h	1999/06/05 11:27:51
***************
*** 34,39 ****
--- 34,41 ----
  #ifndef _CPP_BITS_STRING_H
  #define _CPP_BITS_STRING_H	1
  
+ namespace std {
+ 
  #if _G_USE_EXCEPTIONS
    // Internal functions for string implementation.
    extern void __out_of_range(const char *__str);
***************
*** 48,55 ****
  # define __OUTOFRANGE(__cond) assert(!(__cond))
  # define __LENGTHERROR(__cond) assert(!(__cond))
  #endif
- 
- namespace std {
  
    // Documentation?  What's that? 
    // Nathan Myers <ncm@cantrip.org>.
--- 50,55 ----


Alfred

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]