Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / CodeWarrior / December 2003



Tip: Looking for answers? Try searching our database.

Bug in MSL

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Hendrik Schober - 05 Dec 2003 14:24 GMT
Hi,

I have this code:

 #include <iostream>
 #include <bitset>

 template< std::size_t N >
 void test()
 {
   std::cout << N << "bit:\n";
   std::bitset<N> bset; std::cout << bset << '\n';
   bset.set();          std::cout << bset << '\n';
   bset.reset();        std::cout << bset << '\n';
   bset.set();          std::cout << bset << "\n\n";
 }

 int main()
 {
   test<31>();
   test<32>();
   test<33>();
   return 0;
 }

Using VC7.1 (Dinkumware std lib) results in

 31bit:
 0000000000000000000000000000000
 1111111111111111111111111111111
 0000000000000000000000000000000
 1111111111111111111111111111111

 32bit:
 00000000000000000000000000000000
 11111111111111111111111111111111
 00000000000000000000000000000000
 11111111111111111111111111111111

 33bit:
 000000000000000000000000000000000
 111111111111111111111111111111111
 000000000000000000000000000000000
 111111111111111111111111111111111

which is just what I would have thought.
However, CW9.1 results in

 31bit:
 0000000000000000000000000000000
 1111111111111111111111111111111
 0000000000000000000000000000000
 1111111111111111111111111111111

 32bit:
 00000000000000000000000000000000
 00000000000000000000000000000000
 00000000000000000000000000000000
 00000000000000000000000000000000

 33bit:
 000000000000000000000000000000000
 111111111111111111111111111111111
 000000000000000000000000000000000
 111111111111111111111111111111111

I think this is a bug.

Schobi

Signature

SpamTrap@gmx.de is never read
I'm Schobi at suespammers dot org

"Sometimes compilers are so much more reasonable than people."
 Scott Meyers

Howard Hinnant - 05 Dec 2003 16:35 GMT
> Hi,
>
[quoted text clipped - 41 lines]
>
> I think this is a bug.

I think you're right!  Sorry about that.  This will be fixed for the
next patch.  If you would like to patch up your own version of <bitset>,
open it up, go to line 599.

Change:

   data_ = mask;

to:

   data_ = mask ? mask : (unsigned long)(-1);

Go to line 648.

Change:

   data_ &= mask;

to:

   if (mask)
       data_ &= mask;

No need to recompile the C++ library, but rebuild precompiled headers if
you use them.

My apologies again for the inconvenience this caused you, and thanks
very much for reporting it.

-Howard
Hendrik Schober - 05 Dec 2003 16:44 GMT
> [...]
> I think you're right!  Sorry about that.  This will be fixed for the
> next patch.  If you would like to patch up your own version [...]

 Thanks for the ACK, Howard.

> -Howard

 Schobi

Signature

SpamTrap@gmx.de is never read
I'm Schobi at suespammers dot org

"Sometimes compilers are so much more reasonable than people."
 Scott Meyers

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.