[LLVMbugs] [Bug 23156] New: std::is_integral<__int128>::value is false with libstdc++ from GCC 5.

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Apr 7 19:09:55 PDT 2015


https://llvm.org/bugs/show_bug.cgi?id=23156

            Bug ID: 23156
           Summary: std::is_integral<__int128>::value is false with
                    libstdc++ from GCC 5.
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: toojays at toojays.net
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

g++-5 (Ubuntu 5-20150329-1ubuntu11~14.04) 5.0.0 20150329 (experimental) [trunk
revision 221764]
Ubuntu clang version 3.6.1-svn232753-1~exp1 (branches/release_36) (based on
LLVM 3.6.1)

jscott at citra:/tmp$ cat int128.cpp 
#include <type_traits>

int main ()
{
  static_assert(std::is_integral<__int128>::value, "__int128 should be
integral");
  return 0;
}
jscott at citra:/tmp$ g++-5 -std=gnu++11 -c int128.cpp 
jscott at citra:/tmp$ clang++ -std=gnu++11 -c int128.cpp 
int128.cpp:5:3: error: static_assert failed "__int128 should be integral"
  static_assert(std::is_integral<__int128>::value, "__int128 should be
integral");
  ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.


With GCC 4.9, this program builds fine.

This breakage appears to be due to the following GCC change:
http://permalink.gmane.org/gmane.comp.gcc.cvs/165545

In GCC 4.9 there was a symbol _GLIBCXX_USE_INT128 defined somewhere (maybe in
some config header? I'm not sure) which let this work. With GCC 5,
__GLIBCXX_TYPE_INT_N_0 and __GLIBCXX_BITSIZE_INT_N_0 are built into the
preprocessor, and must be defined to let type_traits acknowledge __int128 as an
integer.


I discovered this issue due to some code which uses GCC's SIMD Mersenne Twister
extension. A minimal example is:

#include <ext/random>

typedef __gnu_cxx::simd_fast_mersenne_twister_engine<
  unsigned __int128,
  /* The following parameters all relate to Mersenne Twister internal
   * state. These are thoughtlessly copied from the definition of sfmt19937.
   */
  19937, 122,
  18, 1, 11, 1,
  0xdfffffefU, 0xddfecb7fU,
  0xbffaffffU, 0xbffffff6U,
  0x00000001U, 0x00000000U,
  0x00000000U, 0x13c9e684U>
sfmt19937_128;

int main ()
{
  sfmt19937_128 engine;
  auto value = engine();
}

Which fails to build with Clang 3.6 + libstdc++ 5.0 like:

jscott at citra:/tmp$ clang++ -std=gnu++11 random.cpp
In file included from random.cpp:1:
/usr/bin/../lib/gcc/x86_64-linux-gnu/5.0.0/../../../../include/c++/5.0.0/ext/random:67:7:
error: static_assert failed "template argument substituting _UIntType not an
unsigned integral type"
      static_assert(std::is_unsigned<_UIntType>::value, "template argument "
      ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
random.cpp:18:17: note: in instantiation of template class
'__gnu_cxx::simd_fast_mersenne_twister_engine<unsigned __int128, 19937, 122,
18, 1, 11, 1, 3758096367, 3724462975, 3220897791, 3221225462, 1, 0, 0,
      331998852>' requested here
  sfmt19937_128 engine;
                ^
1 error generated.


With the following definitions added to the top of the file it builds. Haven't
tried a real example to see if it works though.

"""
#define __GLIBCXX_BITSIZE_INT_N_0 128
#define __GLIBCXX_TYPE_INT_N_0 __int128
"""

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150408/e7e13873/attachment.html>


More information about the llvm-bugs mailing list