Uploaded image for project: 'C++ Standard Library'
  1. C++ Standard Library
  2. STDCXX-297

std::bitset constructor addressed memory beyond the object

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • 4.1.3
    • 4.2.0
    • 23. Containers
    • None
    • All

    Description

      he program below fails:

      ------------------------------------------
      #include <cassert>
      #include <new>
      #include <bitset>
      #include <string>
      #include <cstddef>
      #include <string.h>

      int main ()
      {
      typedef std::bitset<128> BitSet;
      const std::size_t size = sizeof (BitSet);

      char buf [size + 4];
      memset (buf, '\xff', sizeof (buf));

      BitSet* btest = new (buf) BitSet (std::basic_string<int> ());

      for (std::size_t i = size; i < sizeof (buf); ++i)
      assert ('\xff' == buf [i]);

      btest->~BitSet ();

      return 0;
      }
      ------------------------------------------
      Assertion failed: '\xff' == buf [i], file test.cpp, line 19

      This application has requested the Runtime to terminate it in an unusual way.
      Please contact the application's support team for more information.
      ------------------------------------------

      Attachments

        Activity

          People

            farid Farid Zaripov
            farid Farid Zaripov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: