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

Travis Vitek commented on STDCXX-1055:
--------------------------------------

{quote="Stefan Teleman"}
It is not true that money_base and time_base are not allowed to have virtual 
destructors. The Standard specification does not provide any declaration for 
these classes' destructors at all
{quote}

As you see from your snippet, the C++ Standard doesn't explicitly list them in 
the interface and as far as I can tell, it doesn't require them. As mentioned 
previously, they are only required in the derived facet classes (which get it 
from their other base {{std::locale::facet}}).

As you pointed out above, relying on these classes having behavior not required 
by the standard _leads to writing very unportable code_. Example...

{code}

#include <locale>
#include <cassert>

bool virtual_destructor = false;

struct A : std::time_base
{
  /* virtual */ ~A() {
      virtual_destructor = true;
  }
};

int main ()
{
    std::time_base* p = new A;
    delete p;

    assert (virtual_destructor);
}
{code}

This code assumes that the destructor in the base is virtual. It is 
non-portable. It asserts on gcc-4.3.4, gcc-4.4.5, sunpro-5.10 using stlport4 
and the default standard library, as well as acc-6.25. The test runs to 
completion (implying that the destructor is virtual) on msvc-11.0 and 
vacpp-11.1.

If you have some sort of conformance test that verifies the destructor of these 
bases is virtual, I'm going to suggest that the conformance test is incorrect, 
or is at least verifying conformance with the Dinkumware C++ Standard Library.
                
> some of the localization class declarations do not follow the 
> ISO/IEC:14882:2003 specification
> ----------------------------------------------------------------------------------------------
>
>                 Key: STDCXX-1055
>                 URL: https://issues.apache.org/jira/browse/STDCXX-1055
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 22. Localization
>    Affects Versions: 4.2.1, 4.2.2, 4.2.x, 4.3.x, 5.0.0
>         Environment: Solaris 10 and 11, Linux (RedHat and OpenSUSE), Sun C++ 
> Compiler 12.1, 12.2, 12.3, GCC4.
> The defect is independent of platform or compiler.
>            Reporter: Stefan Teleman
>              Labels: conformance, standards
>             Fix For: 4.2.x, 4.3.x, 5.0.0
>
>         Attachments: stdcxx-1055.patch
>
>
> For the following classes:
> std::codecvt<> and its specializations
> std::collate<> and its specializations
> std::ctype<> and its specializations
> std::ctype_byname<> and its specializations
> std::messages<> and its specializations
> std::messages_byname<> and its specializations
> std::money_get<> and its specializations
> std::moneypunct<> and is specializations
> std::moneypunct_byname<> and its specializations
> std::money_put<> and its specializations
> std::num_get<> and its specializations
> std::numpunct<> and its specializations
> std::numpunct_byname<> and its specializations
> std::num_put<> and its specializations
> std::time_get<> and its specializations
> std::time_get_byname<> and its specializations
> std::time_put<> and its specializations
> 1. all these type declarations must be of class type (and not of struct type)
> 2. all these classes must have protected virtual destructors
> 3. all the corresponding *_base (time_base, money_base, etc), must have 
> virtual destructors
> The current implementation of these types as structs (with default public 
> access
> specifier on their non-virtual destructors) causes failures in Perennial 
> CPPVS V8.1.
> Changing the access specifier for these destructors requires some changes in 
> the
> stdcxx tests for localization.
> Patch based on 4.2.1 to follow shortly.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to