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

[MSVC 8-x64] 21.string.cons.cpp test fails in optimized builds due to bad codegeneration by the compiler

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 4.2.0
    • Fix Version/s: 4.2.1
    • Component/s: Tests
    • Labels:
      None
    • Environment:

      MSVC 8.0-x64, builds 8

      {d|s}, 12{d|s}
    • Severity:
      Incorrect Behavior

      Description

      The 21.string.cons.cpp test fails with 16 assertions on 64-bit MSVC in optimized builds.
      The reason is the bad codegeneration in __rw_new_capacity() inlined in std::basic_string ctors. Because of this bug the __rw_new_capacity(0, const std::basic_string<> *) returns value greater that size_max() and ctor throws exception.

      The temporary workaround might be definition of the __rw_new_capacity() as __declspec (noinline).

      ------------------------------
      Index: include/string
      ===================================================================
      — include/string (revision 593511)
      +++ include/string (working copy)
      @@ -1528,8 +1528,13 @@
      // more specialized version for basic_string<>; may be further specialized // in user code for example on a user-defined allocator

      +#if !defined (_WIN64) || !defined (_MSC_VER) || defined
      (__INTEL_COMPILER)
      template <class _CharT, class _Traits, class _Allocator> inline _RWSTD_STRING_SIZE_TYPE
      +#else // WIN64 && _MSC_VER && !_INTEL_COMPILER
      +template <class _CharT, class _Traits, class _Allocator> __declspec
      +(noinline) _RWSTD_STRING_SIZE_TYPE
      +#endif // !_WIN64 || !_MSC_VER || __INTEL_COMPILER
      __rw_new_capacity (_RWSTD_STRING_SIZE_TYPE __size,
      const _STD::basic_string<_CharT, _Traits,
      _Allocator>*)
      {
      ------------------------------

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                farid Farid Zaripov
                Reporter:
                farid Farid Zaripov
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: