stdcxx-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Sebor (JIRA)" <j...@apache.org>
Subject [jira] Commented: (STDCXX-680) use_facet and has_facet are unreliable unless dynamic_cast is available
Date Sun, 06 Apr 2008 23:12:24 GMT

    [ https://issues.apache.org/jira/browse/STDCXX-680?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12586200#action_12586200
] 

Martin Sebor commented on STDCXX-680:
-------------------------------------

Test case:

{noformat}
$ cat t.cpp && gmake t && LC_ALL=en_US ./t
#include <cassert>
#include <locale>

struct MyNumpunct: std::numpunct<char> { };
struct MyNumpunctByname: std::numpunct<char> { };

int main ()
{
    const std::locale classic (std::locale::classic ());
    const std::locale named ("");

    assert (std::has_facet<std::numpunct<char> >(classic));
    assert (!std::has_facet<MyNumpunct>(classic));
    assert (!std::has_facet<std::numpunct_byname<char> >(classic));
    assert (!std::has_facet<MyNumpunctByname>(classic));

    if (named != classic) {
        assert (std::has_facet<std::numpunct<char> >(named));
        assert (!std::has_facet<MyNumpunct>(named));
        assert (std::has_facet<std::numpunct_byname<char> >(named));
        assert (!std::has_facet<MyNumpunctByname>(named));
    }
}
xlCcore -c -I/amd/devco/sebor/stdcxx/include/ansi    -I/amd/devco/sebor/stdcxx/include -I/build/sebor/stdcxx-xlC-9.0-8d/include
-I/amd/devco/sebor/stdcxx/examples/include  -O     -qtemplateregistry=t.ti t.cpp
xlCcore t.o -o t -I/amd/devco/sebor/stdcxx/include/ansi    -liconv -brtl    -L/build/sebor/stdcxx-xlC-9.0-8d/lib
 -Wl,-bsvr4,-R/build/sebor/stdcxx-xlC-9.0-8d/lib -lstd8d  -lm -qtemplateregistry=t.ti
Assertion failed: !std::has_facet<MyNumpunct>(classic), file  t.cpp, line 13
IOT/Abort trap (core dumped)
{noformat}

> use_facet and has_facet are unreliable unless dynamic_cast is available
> -----------------------------------------------------------------------
>
>                 Key: STDCXX-680
>                 URL: https://issues.apache.org/jira/browse/STDCXX-680
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 22. Localization
>    Affects Versions: 4.2.0
>            Reporter: Travis Vitek
>
> The function that is called by has_facet<>() and use_facet<>() uses _RWSTD_DYNAMIC_CAST
in an attempt to check that the returned locale facet is of the requested type. Unfortunately,
if RTTI is not supported or enabled, that cast becomes unreliable.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message