#193 cmath and ansi

closed-fixed
Danny Smith
gcc (462)
2002-10-05
2002-09-27
Xavier Trochu
No

There is a bug that occur when compiling with the -ansi
and when including <cmath> header.

a simple test :

test.cpp
#include <cmath>

$ gcc -c test.cpp
In file included from base_math_test.cpp:1:
c:/tools/mingw/include/c++/3.2/cmath: In function
`float std::acos(float)':
c:/tools/mingw/include/c++/3.2/cmath:99: `::acosf'
undeclared (first use here)
...

The problem is that _mingw.h define
_GLIBCPP_HAVE_ACOSF even when compiling with -ansi
but math.h does not declare the acosf() function if
__STRICT_ANSI__ is not defined.

Discussion

  • Xavier Trochu
    Xavier Trochu
    2002-09-27

    Logged In: YES
    user_id=1927

    please note that this is new and the software that produced
    the bug compiled fine with gcc 3.1

    I forgot to mention that it was for gcc 3.2

     
  • Danny Smith
    Danny Smith
    2002-09-28

    Logged In: YES
    user_id=11494

    What is version of mingw-runtime (in _mingw.h). I
    though this bug was fixed by a change in math.h
    that protected C99 math with:

    #if (defined (__STDC_VERSION__) &&
    __STDC_VERSION__ >= 199901L) \ || !defined __STRICT_ANSI__ || defined
    __GLIBCPP__

    so that C99 math was available to __GLIBCPP__

    Actually, in hindsight, I think this is the wrong fix. the
    guard should be something more strict like:
    defined __GLIBCPP_USE_C99

    In even stricter sense, C++98 shouldn't be exposing
    C99 functions which are not part of C++98 std.

    If you are using mingw runtime earlier than 2.2 , please
    update and tell me if problem persists.

    Danny

     
  • Danny Smith
    Danny Smith
    2002-09-28

    Logged In: YES
    user_id=11494

    A correction to my last comment:
    I said:
    'In even stricter sense, C++98 shouldn't be exposing
    C99 functions which are not part of C++98 std'

    That is not qute right. The overloaded math finction
    like cos(float) cos(double) cos(long double) are part of
    C++ standard, but the specific typed ones like cosf and
    cosl are not.

    Danny

    Danny

     
  • Xavier Trochu
    Xavier Trochu
    2002-09-29

    Logged In: YES
    user_id=1927

    Updating to runtime-2.2 corrected the issue.

    Sorry for all this.

    Greetings,

    Xavier

     
  • Danny Smith
    Danny Smith
    2002-10-05

    Logged In: YES
    user_id=11494

    Fixed in current runtime.
    Danny

     
  • Danny Smith
    Danny Smith
    2002-10-05

    • status: open --> closed-fixed