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
Confirmed, I will apply a variant (__n is unsigned here and the original expression can be simplified) of your patch momentarily, after testing. Of course the issue is really noticeable only on 32-bit machines...
Subject: Bug 45713 Author: paolo Date: Sat Sep 18 01:29:31 2010 New Revision: 164388 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=164388 Log: 2010-09-17 Luc Hermitte <hermitte@free.fr> Paolo Carlini <paolo.carlini@oracle.com> PR libstdc++/45713 * include/std/bitset: Fix _GLIBCXX_BITSET_WORDS macro. * testsuite/23_containers/bitset/45713.cc: New. Added: trunk/libstdc++-v3/testsuite/23_containers/bitset/45713.cc Modified: trunk/libstdc++-v3/ChangeLog trunk/libstdc++-v3/include/std/bitset
Fixed for 4.6.0.