Opened 5 years ago

Closed 5 years ago

#13315 closed Support Requests (wontfix)

boost 1.65.1 gcc 5.4 redefinition error in boost/type_traits/is_unsigned.hpp

Reported by: wiki908@… Owned by: John Maddock
Milestone: Boost 1.65.0 Component: type_traits
Version: Boost 1.65.0 Severity: Problem
Keywords: Cc:

Description

This is my gcc version:

root# g++ -v

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-linux-gnueabihf/5/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 5.4.1-2ubuntu1~14.04' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=gcc4-compatible --disable-libstdcxx-dual-abi --enable-gnu-unique-object --disable-libitm --disable-libquadmath --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-armhf/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-armhf --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-armhf --with-arch-directory=arm --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --enable-multilib --disable-sjlj-exceptions --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-mode=thumb --disable-werror --enable-multilib --enable-checking=release --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf
Thread model: posix
gcc version 5.4.1 20160904 (Ubuntu/Linaro 5.4.1-2ubuntu1~14.04) 

When I am building ViennaCL, I got this error:

makefile# cd /root/viennacl-dev/build/tests && /usr/bin/c++    --std=c++11 -O3 -DNDEBUG -I/root/viennacl-dev -I/usr/local/include -I/root/viennacl-dev/external -I/root/viennacl-dev/libviennacl/include    -DVIENNACL_WITH_OPENCL -o CMakeFiles/external_linkage-opencl.dir/src/external_2.cpp.o -c /root/viennacl-dev/tests/src/external_2.cpp

In file included from /usr/local/include/boost/type_traits.hpp:127:0,
                 from /usr/local/include/boost/numeric/ublas/traits.hpp:27,
                 from /usr/local/include/boost/numeric/ublas/storage.hpp:26,
                 from /usr/local/include/boost/numeric/ublas/storage_sparse.hpp:23,
                 from /usr/local/include/boost/numeric/ublas/vector_sparse.hpp:16,
                 from /usr/local/include/boost/numeric/ublas/matrix_sparse.hpp:16,
                 from /root/viennacl-dev/viennacl/meta/result_of.hpp:32,
                 from /root/viennacl-dev/viennacl/scalar.hpp:29,
                 from /root/viennacl-dev/tests/src/external_2.cpp:34:
/usr/local/include/boost/type_traits/is_unsigned.hpp:126:20: error: redefinition of ‘struct boost::is_unsigned<long long unsigned int>’
 template <> struct is_unsigned<const ::boost::ulong_long_type> : public true_type{};
                    ^
/usr/local/include/boost/type_traits/is_unsigned.hpp:125:20: error: previous definition of ‘struct boost::is_unsigned<long long unsigned int>’
 template <> struct is_unsigned< ::boost::ulong_long_type> : public true_type{};
                    ^

With or without `--std=c++11' didn't help.

Other info. I installed GCC 5 via ppa.

root# lsb_release -a

No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 14.04.1 LTS
Release:	14.04
Codename:	trusty

root# uname -a

Linux firefly 3.10.0 #128 SMP PREEMPT Tue Aug 15 16:17:29 CST 2017 armv7l armv7l armv7l GNU/Linux

I didn't meed the error when I use GCC 4.8.4 with libboost 1.54.

What should I do to solve the problem, thank you very much!

Change History (4)

comment:1 by anonymous, 5 years ago

Summary: gcc 5.4 redefinition error in boost/type_traits/is_unsigned.hppboost 1.65.1 gcc 5.4 redefinition error in boost/type_traits/is_unsigned.hpp

comment:2 by Michel Morin, 5 years ago

I think this is a compiler bug (though I don't understand what happens in the code). Here is a smaller testcase

#include <iostream>

typedef unsigned long long cl_ulong __attribute__((aligned(8)));

void f()
{
    // unsigned long long x; // OK
    cl_ulong x; // Error
    std::cout << x;
}

template <class T> struct is_unsigned {};
template <> struct is_unsigned<      unsigned long long> {};
template <> struct is_unsigned<const unsigned long long> {};

G++-5 fails to compile the code on C++11, 14, 17 modes with the following error messages

Line14: error: redefinition of 'struct is_unsigned<long long unsigned int>'
 template <> struct is_unsigned<const unsigned long long> {};
                    ^
Line13: error: previous definition of 'struct is_unsigned<long long unsigned int>'
 template <> struct is_unsigned<      unsigned long long> {};

comment:3 by Michel Morin, 5 years ago

I reported the compiler bug to GCC as PR83248. There, I got this reply

GCC 5 is no longer maintained, if it is fixed in GCC 6 please use that.

GCC 6, 7, 8 do not have this compiler bug.

comment:4 by John Maddock, 5 years ago

Resolution: wontfix
Status: newclosed

I'm going to close this, purely because I don't see any way to fix this without breaking other stuff... please file a PR if you see a way.

Note: See TracTickets for help on using tickets.