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

22.locale.numpunct.mt fails because of inconsistencies between C and C++ locales

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 4.2.0
    • Fix Version/s: 4.2.0
    • Component/s: Tests
    • Labels:
      None
    • Patch Info:
      Patch Available
    • Severity:
      Incorrect Behavior

      Description

      The current numpunct.mt test fails on at least one platform because the initialization code and the test code use two different methods for retrieving the numpunct data. The run_test function uses std::localeconv(), and thread_func uses the C++ locale numpunct facet. In most situations this isn't a problem.

      Unfortunately, due to incompatibilities between the C and C++ locale details, the thousands seperator is different with the "C" locale. For C++ it is ',' and for C it is the empty string. Here is a quick test to show the problem that the test sees.

      #include <clocale>
      #include <locale>

      int main()
      {
      if (!std::setlocale (LC_ALL, "C"))
      return 1;

      const std::lconv* const pconv = std::localeconv ();

      // test against the specialization directly
      const std::numpunct<char> np(0);

      assert (*pconv->decimal_point == np.decimal_point ());
      assert (*pconv->thousands_sep == np.thousands_sep ());

      return 0;
      }

      The test should be enhanced to use the C++ locale for both run_test and thread_func.

        Attachments

        1. stdcxx-571.patch
          9 kB
          Travis Vitek
        2. 22.locale.numpunct.mt.cpp
          10 kB
          Travis Vitek

          Activity

            People

            • Assignee:
              vitek Travis Vitek
              Reporter:
              vitek Travis Vitek
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: