[Bug c++/56671] Gcc uses large amounts of memory and processor power with large C++11 bitsets

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Jan 26 15:12:00 GMT 2016


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56671

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2016-01-26
     Ever confirmed|0                           |1

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Generating the array initialization for this constexpr constructor is the
problem:

      constexpr _Base_bitset(unsigned long long __val) noexcept
      : _M_w{ _WordT(__val)
       } { }

Reduced example from PR 69486:

namespace std
{
  typedef decltype(sizeof(0)) size_t;

  template<size_t _Nw>
    struct _Base_bitset
    {
      typedef unsigned long _WordT;

      _WordT _M_w[_Nw];

      constexpr _Base_bitset() noexcept
      : _M_w() { }

      constexpr _Base_bitset(unsigned long long __val) noexcept
      : _M_w{ _WordT(__val)
       } { }
    };

  template<size_t _Nb>
    class bitset
    : private _Base_bitset<((_Nb) / (8 * 8) + ((_Nb) % (8 * 8) == 0 ? 0 : 1))>
    {
    public:
      constexpr bitset() noexcept
      { }
    };
}

std::bitset<2147483648> b;
int main() {}


More information about the Gcc-bugs mailing list