[Top][All Lists]

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

Re: signbit issues

From: Orion Poplawski
Subject: Re: signbit issues
Date: Fri, 19 Feb 2016 14:05:44 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0

On 02/19/2016 12:45 PM, Paul Eggert wrote:
> On 02/19/2016 11:32 AM, Orion Poplawski wrote:
>> g++ -DHAVE_CONFIG_H -I. -I..  -I../lib   -g -O2 -MT foobar.o -MD -MP -MF
>> .deps/foobar.Tpo -c -o foobar.o foobar.cpp
>> In file included from foobar.cpp:3:0:
>> ../lib/math.h: In function ‘int signbit(float)’:
>> ../lib/math.h:2576:1: error: ‘int signbit(float)’ conflicts with a previous
>> declaration
> This is a C++ thing, plus I don't have GCC 6, so I'm afraid you'll have to do
> most of the legwork.
> Why was Gnulib trying to define its own signbit function? Why didn't the
> signbit function from GCC 6 pass Gnulib's test? Look in config.log to find
> out. On my platform (Fedora 23, GCC 5.3.1) signbit passes all the tests so
> there's no reason for Gnulib to try to substitute its own.

It appears that if gnulib detects the "signbit compiler built-ins" it insists
on using them.

I end up with:


configure:7721: checking for signbit macro
configure:7826: gcc -o conftest -g -O2   conftest.c  >&5
configure:7826: $? = 0
configure:7826: ./conftest
configure:7826: $? = 0
configure:7837: result: yes
configure:7839: checking for signbit compiler built-ins
configure:7941: gcc -o conftest -g -O2   conftest.c  >&5
configure:7941: $? = 0
configure:7941: ./conftest
configure:7941: $? = 0
configure:7952: result: yes

and math.h has:

#if 1
# if 1
#  undef signbit
   /* GCC 4.0 and newer provides three built-ins for signbit.  */
#  define signbit(x) \
   (sizeof (x) == sizeof (long double) ? __builtin_signbitl (x) : \
    sizeof (x) == sizeof (double) ? __builtin_signbit (x) : \
    __builtin_signbitf (x))
# endif

# ifdef __cplusplus
#  ifdef signbit
#   undef signbit
#  endif
# endif

In the preprocessed output I get:

  constexpr bool
  signbit(float __x)
  { return __builtin_signbit(__x); }

  constexpr bool
  signbit(double __x)
  { return __builtin_signbit(__x); }

  constexpr bool
  signbit(long double __x)
  { return __builtin_signbit(__x); }

  template<typename _Tp>
    constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
    signbit(_Tp __x)
    { return __x < 0 ? true : false; }

from /usr/include/c++/6.0.0/cmath


inline int signbit (float f) { return _gl_cxx_signbitf (f); } inline int
signbit (double d) { return _gl_cxx_signbitd (d); } inline int signbit (long
double l) { return _gl_cxx_signbitl (l); }

from lib/math.h (gnulib).

But this is incompatible with the new g++ 6 definitions.

Orion Poplawski
Technical Manager                     303-415-9701 x222
NWRA, Boulder/CoRA Office             FAX: 303-415-9702
3380 Mitchell Lane                       address@hidden
Boulder, CO 80301                   http://www.nwra.com

reply via email to

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