Hello,

std::bitset cannot be instantiated with an extremely big number of bits like
ULONG_MAX.
e.g.
--------- >% --------------
#include <iostream>
#include <bitset>

int main()
{
    std::cout << sizeof (std::bitset<0xffffffff>) << std::endl;
}
--------- >% --------------
outputs 1 with g++ 3.4.4 and 4.3.4 on cygwin, and with gcc 3.4.? on Solaris.

It seems related to the macro _GLIBCXX_BITSET_WORDS that overflows. With a
simple division + modulo formula, the bug vanishes.
i.e.

#define _GLIBCXX_BITSET_WORDS(__n) \
 ((__n) < 1 ? 0 : (((__n)/_GLIBCXX_BITSET_BITS_PER_WORD) +
(((__n)%_GLIBCXX_BITSET_BITS_PER_WORD==0)?0:1)))

HTH,

--Luc Hermitte


-- 
           Summary: sizeof std::bitset<ULONG_MAX> == 1
           Product: gcc
           Version: 3.4.4
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: hermitte at free dot fr
 GCC build triplet: -
  GCC host triplet: -
GCC target triplet: -


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45713

Reply via email to