stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Farid Zaripov" <Farid_Zari...@epam.com>
Subject 22.locale.moneypunct test fails on MSVC
Date Wed, 03 Oct 2007 18:23:43 GMT
  The 22.locale.moneypunct test fails on MSVC (and ICC/Windows)
due to bug of the CRT or native API.

  The following program aborts on assert (tested on all
MSVC's on Windows XP 32 and 64 bit). This program fails
only for some locales. So it fails with locname = "Catalan_Spain.1252"
but succeeds with locname = "Russian_Russia.1251".

-----------------------
#include <clocale>
#include <cstring>
#include <cassert>
#include <cstdio>

int main(int argc, char* argv[])
{
    const char* locname = "Catalan_Spain.1252";

    std::setlocale (LC_ALL, "C");

    std::setlocale (LC_MONETARY, locname);
    const lconv* pconv = std::localeconv ();
    char curr = pconv->currency_symbol [0];

    std::setlocale (LC_ALL, "C");

    std::setlocale (LC_ALL, locname);
    pconv = std::localeconv ();
    char curr2 = pconv->currency_symbol [0];

    std::printf ("curr = %d\n", int (curr));
    std::printf ("curr2 = %d\n", int (curr2));

    assert (curr == curr2);

    return 0;
}  
-----------------------

  The program output:
-----------------------
curr = -120
curr2 = -128
Assertion failed: curr == curr2, file
d:\_projects\locbug\locbug\locbug.cpp, line 29

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

Farid.

Mime
View raw message