Public bug reported: Environment -----------
Test program compiled on Artful Aardvark Ubuntu 17.10. $ which g++-4.8 /usr/bin/g++-4.8 $ /usr/bin/g++-4.8 --version g++-4.8 (Ubuntu 4.8.5-4ubuntu6) 4.8.5 Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ which g++-4.9 /usr/bin/g++-4.9 $ /usr/bin/g++-4.9 --version g++-4.9 (Ubuntu 4.9.4-2ubuntu1) 4.9.4 Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ which g++-5 /usr/bin/g++-5 $ /usr/bin/g++-5 --version g++-5 (Ubuntu 5.5.0-1ubuntu1) 5.4.1 20171010 Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ which g++-6 /usr/bin/g++-6 $ /usr/bin/g++-6 --version g++-6 (Ubuntu 6.4.0-8ubuntu1) 6.4.0 20171010 Copyright (C) 2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ which g++-7 /usr/bin/g++-7 $ /usr/bin/g++-7 --version g++-7 (Ubuntu 7.2.0-8ubuntu3) 7.2.0 Copyright (C) 2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ dpkg --status libc6-dev:amd64 Package: libc6-dev Status: install ok installed Priority: optional Section: libdevel Installed-Size: 18041 Maintainer: Ubuntu Developers <[email protected]> Architecture: amd64 Multi-Arch: same Source: glibc Version: 2.26-0ubuntu2 Provides: libc-dev Depends: libc6 (= 2.26-0ubuntu2), libc-dev-bin (= 2.26-0ubuntu2), linux-libc-dev (>= 4.13.0) Suggests: glibc-doc, manpages-dev Breaks: binutils (<< 2.26), binutils-gold (<< 2.20.1-11), cmake (<< 2.8.4+dfsg.1-5), gcc-4.4 (<< 4.4.6-4), gcc-4.5 (<< 4.5.3-2), gcc-4.6 (<< 4.6.0-12), libhwloc-dev (<< 1.2-3), libjna-java (<< 3.2.7-4), liblouis-dev (<< 2.3.0-2), liblouisxml-dev (<< 2.4.0-2), make (<< 3.81-8.1), pkg-config (<< 0.26-1) Conflicts: libc0.1-dev, libc0.3-dev, libc6.1-dev Description: GNU C Library: Development Libraries and Header Files Contains the symlinks, headers, and object files needed to compile and link programs which use the standard C library. Homepage: http://www.gnu.org/software/libc/libc.html Original-Maintainer: GNU Libc Maintainers <[email protected]> Test cases that fail -------------------- $ g++-5 -x c++ - <<EOF #include <math.h> int main() { return signbit(1.0); } EOF In file included from <stdin>:1:0: <stdin>: In function ‘int main()’: <stdin>:4:10: error: expected primary-expression before ‘__typeof’ <stdin>:4:10: error: expected primary-expression before ‘float’ <stdin>:4:10: error: ‘__builtin_types_compatible_p’ was not declared in this scope <stdin>:4:10: error: expected primary-expression before ‘__typeof’ <stdin>:4:10: error: expected primary-expression before ‘double’ <stdin>:4:10: error: expected primary-expression before ‘__typeof’ <stdin>:4:10: error: expected primary-expression before ‘long’ <stdin>:4:10: error: ‘__builtin_choose_expr’ was not declared in this scope <stdin>:4:10: error: ‘__builtin_choose_expr’ was not declared in this scope <stdin>:4:10: error: redeclaration of ‘<typeprefixerror>__builtin_choose_expr’ <stdin>:4:10: note: previous declaration ‘<typeprefixerror>__builtin_choose_expr’ <stdin>:4:10: error: ‘__builtin_choose_expr’ was not declared in this scope <stdin>:4:10: error: redeclaration of ‘<typeprefixerror>__builtin_choose_expr’ <stdin>:4:10: note: previous declaration ‘<typeprefixerror>__builtin_choose_expr’ $ g++-4.9 -x c++ - <<EOF #include <math.h> int main() { return signbit(1.0); } EOF In file included from <stdin>:1:0: <stdin>: In function ‘int main()’: <stdin>:4:10: error: expected primary-expression before ‘__typeof’ <stdin>:4:10: error: expected primary-expression before ‘float’ <stdin>:4:10: error: ‘__builtin_types_compatible_p’ was not declared in this scope <stdin>:4:10: error: expected primary-expression before ‘__typeof’ <stdin>:4:10: error: expected primary-expression before ‘double’ <stdin>:4:10: error: expected primary-expression before ‘__typeof’ <stdin>:4:10: error: expected primary-expression before ‘long’ <stdin>:4:10: error: ‘__builtin_choose_expr’ was not declared in this scope <stdin>:4:10: error: ‘__builtin_choose_expr’ was not declared in this scope <stdin>:4:10: error: redeclaration of ‘<typeprefixerror>__builtin_choose_expr’ <stdin>:4:10: note: previous declaration ‘<typeprefixerror>__builtin_choose_expr’ <stdin>:4:10: error: ‘__builtin_choose_expr’ was not declared in this scope <stdin>:4:10: error: redeclaration of ‘<typeprefixerror>__builtin_choose_expr’ <stdin>:4:10: note: previous declaration ‘<typeprefixerror>__builtin_choose_expr’ $ g++-4.8 -x c++ - <<EOF #include <math.h> int main() { return signbit(1.0); } EOF In file included from <stdin>:1:0: <stdin>: In function ‘int main()’: <stdin>:4:10: error: expected primary-expression before ‘__typeof’ <stdin>:4:10: error: expected primary-expression before ‘float’ <stdin>:4:10: error: ‘__builtin_types_compatible_p’ was not declared in this scope <stdin>:4:10: error: expected primary-expression before ‘__typeof’ <stdin>:4:10: error: expected primary-expression before ‘double’ <stdin>:4:10: error: expected primary-expression before ‘__typeof’ <stdin>:4:10: error: expected primary-expression before ‘long’ <stdin>:4:10: error: ‘__builtin_choose_expr’ was not declared in this scope <stdin>:4:10: error: ‘__builtin_choose_expr’ was not declared in this scope <stdin>:4:10: error: redeclaration of ‘<typeprefixerror>__builtin_choose_expr’ <stdin>:4:10: note: previous declaration ‘<typeprefixerror>__builtin_choose_expr’ <stdin>:4:10: error: ‘__builtin_choose_expr’ was not declared in this scope <stdin>:4:10: error: redeclaration of ‘<typeprefixerror>__builtin_choose_expr’ <stdin>:4:10: note: previous declaration ‘<typeprefixerror>__builtin_choose_expr’ Test cases that succeed ----------------------- $ g++-6 -x c++ - <<EOF #include <math.h> int main() { return signbit(1.0); } EOF $ g++-7 -x c++ - <<EOF #include <math.h> int main() { return signbit(1.0); } EOF Expected result --------------- Successful compile and return 0. Supposed cause -------------- The definition of function-like macro __MATH_TG at lines 343-74 of /usr/include/math.h requires some finesse to handle C++ programs. As noted in gcc.gnu.org, "6.59 Other Built-in Functions Provided by GCC" Available: https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html Accessed: 22 October 2017 the built-in functions __builtin_choose_expr and __builtin_types_compatible_p are only available in C. Workaround ---------- Hack /usr/include/math.h and modify line 346 #elif __HAVE_DISTINCT_FLOAT128 to read #elif __HAVE_DISTINCT_FLOAT128 && !__cplusplus This clearly doesn't cover all the cases but you get the picture. ** Affects: glibc (Ubuntu) Importance: Undecided Status: New -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/1725869 Title: libc6-dev:amd64 (2.26-0ubuntu2) has unusable signbit for C++ programs To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/glibc/+bug/1725869/+subscriptions -- ubuntu-bugs mailing list [email protected] https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs
