Discussion:
signbit issues
(too old to reply)
Orion Poplawski
2016-02-05 23:38:08 UTC
Permalink
Raw Message
I'm trying to track down a possible issue with gnulib signbit and gcc 6 as
reported here:

https://savannah.gnu.org/bugs/index.php?47073

In file included from /usr/include/suitesparse/cs.h:5:0,
from ./util/oct-sparse.h:77,
from array/CSparse.cc:55:
../libgnu/math.h: In function 'int signbit(float)':
../libgnu/math.h:2576:1: error: 'int signbit(float)' conflicts with a previous
declaration
_GL_MATH_CXX_REAL_FLOATING_DECL_2 (signbit)
^
In file included from /usr/include/c++/6.0.0/complex:44:0,
from ./util/oct-cmplx.h:27,
from numeric/lo-mappers.h:29,
from array/CSparse.cc:36:
/usr/include/c++/6.0.0/cmath:681:3: note: previous declaration 'constexpr bool
std::signbit(float)'
signbit(float __x)
^~~~~~~

So first I tried setting up a simple project with gnulib an signbit:

../gnulib/gnulib-tool --import signbit

but I'm getting:

$ autoreconf -f
lib/Makefile.am:66: error: GL_GENERATE_FLOAT_H does not appear in AM_CONDITIONAL
autoreconf: automake failed with exit status: 1

m4/float_h.m4 seems to have this:

./m4/float_h.m4: AM_CONDITIONAL([GL_GENERATE_FLOAT_H], [test -n "$FLOAT_H"])

but this isn't getting included perhaps?

$ grep -F m4_include aclocal.m4
m4_include([m4/fpieee.m4])
m4_include([m4/gnulib-common.m4])
m4_include([m4/gnulib-comp.m4])

I'm afraid I'm not very experience with automake/autoconf so perhaps I've
messed something else up.

$ cat configure.ac
AC_INIT(test, 1.0, ***@nwra.com)
AC_CONFIG_SRCDIR(src/foobar.cpp)
AM_INIT_AUTOMAKE
AC_PROG_CC
gl_EARLY
AC_PROG_CXX
AC_PROG_RANLIB
AC_CONFIG_FILES(lib/Makefile)
AC_OUTPUT(Makefile src/Makefile)
gl_iNIT


$ cat Makefile.am
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = lib src
EXTRA_DIST = m4/gnulib-cache.m4 autogen.sh


Any help would be greatly appreciated.
--
Orion Poplawski
Technical Manager 303-415-9701 x222
NWRA, Boulder/CoRA Office FAX: 303-415-9702
3380 Mitchell Lane ***@nwra.com
Boulder, CO 80301 http://www.nwra.com
Orion Poplawski
2016-02-07 21:59:09 UTC
Permalink
Raw Message
Post by Orion Poplawski
I'm afraid I'm not very experience with automake/autoconf so perhaps I've
messed something else up.
$ cat configure.ac
AC_CONFIG_SRCDIR(src/foobar.cpp)
AM_INIT_AUTOMAKE
AC_PROG_CC
gl_EARLY
AC_PROG_CXX
AC_PROG_RANLIB
AC_CONFIG_FILES(lib/Makefile)
AC_OUTPUT(Makefile src/Makefile)
gl_iNIT
Small but important typo, that should be "gl_INIT".
AC_CONFIG_SRCDIR(src/foobar.cpp)
AM_INIT_AUTOMAKE(foreign)
AC_PROG_CC
AC_PROG_CXX
AC_PROG_RANLIB
gl_EARLY
gl_INIT
AC_CONFIG_HEADERS(config.h)
AC_CONFIG_FILES(Makefile lib/Makefile src/Makefile)
AC_OUTPUT
Ah, thank you very much for catching that. Now with a simple:

#include <config.h>
#include <math.h>
#include <cmath>

int main(int argc,char **argv) {
}

I'm able to reproduce the compile error:

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:2:0:
../lib/math.h: In function ‘int signbit(float)’:
../lib/math.h:2576:1: error: ‘int signbit(float)’ conflicts with a
previous declaration
_GL_MATH_CXX_REAL_FLOATING_DECL_2 (signbit)
^
In file included from /usr/include/c++/6.0.0/math.h:36:0,
from ../lib/math.h:27,
from foobar.cpp:2:
/usr/include/c++/6.0.0/cmath:681:3: note: previous declaration
‘constexpr bool std::signbit(float)’
signbit(float __x)
^~~~~~~
In file included from foobar.cpp:2:0:
../lib/math.h: In function ‘int signbit(double)’:
../lib/math.h:2576:1: error: ‘int signbit(double)’ conflicts with a
previous declaration
_GL_MATH_CXX_REAL_FLOATING_DECL_2 (signbit)
^
In file included from /usr/include/c++/6.0.0/math.h:36:0,
from ../lib/math.h:27,
from foobar.cpp:2:
/usr/include/c++/6.0.0/cmath:685:3: note: previous declaration
‘constexpr bool std::signbit(double)’
signbit(double __x)
^~~~~~~
In file included from foobar.cpp:2:0:
../lib/math.h: In function ‘int signbit(long double)’:
../lib/math.h:2576:1: error: ‘int signbit(long double)’ conflicts with a
previous declaration
_GL_MATH_CXX_REAL_FLOATING_DECL_2 (signbit)
^
In file included from /usr/include/c++/6.0.0/math.h:36:0,
from ../lib/math.h:27,
from foobar.cpp:2:
/usr/include/c++/6.0.0/cmath:689:3: note: previous declaration
‘constexpr bool std::signbit(long double)’
signbit(long double __x)
^~~~~~~

Although I really don't have any good ideas about how to fix this.
--
Orion Poplawski
Technical Manager 303-415-9701 x222
NWRA, Boulder/CoRA Office FAX: 303-415-9702
3380 Mitchell Lane ***@nwra.com
Boulder, CO 80301 http://www.nwra.com
Paul Eggert
2016-02-20 15:56:14 UTC
Permalink
Raw Message
Thanks, I didn't understand those comments about #defining signbit to 1, but it
does appear that the recent patch should apply only if C++11 or later, so I
installed the attached further patch into gnulib.
Vlad Zakharov
2016-09-29 10:21:36 UTC
Permalink
Raw Message
Hello,

I found the same issue as discussed in this thread.

I tried to build "lftp" package for both ARC and ARM architectures using GCC 6.2 and an error occurred:
---------------------------------->8------------------------------------
../lib/math.h:2577:1: error: ‘int signbit(float)’ conflicts with a previous declaration
_GL_MATH_CXX_REAL_FLOATING_DECL_2 (signbit)
---------------------------------->8------------------------------------
But when I am building it using GCC 4 or 5, I don't see any errors.

Lftp uses lib/math.h from gnulib. As I have mentioned the patch you attached earlier in the thread was already applied,
so issue must occur for some other reason.

Any ideas? 

Thanks.
/
Thanks, I didn't understand those comments about #defining signbit to 1, but it 
does appear that the recent patch should apply only if C++11 or later, so I 
installed the attached further patch into gnulib.
--
Best regards,
Vlad Zakharov <***@s

Paul Eggert
2016-02-20 01:10:03 UTC
Permalink
Raw Message
That appears to do the trick. Thanks.
OK, I installed that. Savannah is currently very slow, so it may take a while
for you to get it.
Orion Poplawski
2016-02-19 22:43:08 UTC
Permalink
Raw Message
Post by Orion Poplawski
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
../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.
Another thing that may be relevant - it appears that with 6.0.0,
/usr/include/c++/6.0.0/cmath does:

#define _GLIBCXX_INCLUDE_NEXT_C_HEADERS
#include_next <math.h>
#undef _GLIBCXX_INCLUDE_NEXT_C_HEADERS

which appears to have the effect of forcing it to include /usr/include/math.h
instead of the math.h from gnulib, which I expect is how gnulib worked before.
--
Orion Poplawski
Technical Manager 303-415-9701 x222
NWRA, Boulder/CoRA Office FAX: 303-415-9702
3380 Mitchell Lane ***@nwra.com
Boulder, CO 80301 http://www.nwra.com
Loading...