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

Stefan Teleman commented on STDCXX-1055:
----------------------------------------

{code:title=test_non_virtual.cc|borderStyle=solid}
#include <iostream>

class foo_base
{
public:
    enum { one, two, three, four, five };

    foo_base() { }
    ~foo_base() { std::cerr << "foo_base::~foo_base()" << std::endl; }
    virtual void print() = 0; // because I don't like casting
};

class bar
{
public:
    bar() { }
    virtual ~bar() { std::cerr << "virtual bar::~bar()" << std::endl; }
};

class foobar : public foo_base, public bar
{
public:
    foobar() { }
    virtual ~foobar() { std::cerr << "virtual foobar::~foobar()" << std::endl; }

    virtual void print()
    {
        std::cerr << "one: " << one << " two: " << two << " three: "
                  << three << " four: " << four << " five: " << five
                  << std::endl;
    }
};

int main()
{
    foo_base* fb = new foobar();

    fb->print();
    delete fb;

    std::cerr.flush();

    return 0;
}
{code}

{code:title=test_virtual.cc|borderStyle=solid}
#include <iostream>

class foo_base
{
public:
    enum { one, two, three, four, five };

    foo_base() { }
    virtual ~foo_base()
    { std::cerr << "virtual foo_base::~foo_base()" << std::endl; }
    virtual void print() = 0; // I don't like casting here either
};

class bar
{
public:
    bar() { }
    virtual ~bar() { std::cerr << "virtual bar::~bar()" << std::endl; }
};

class foobar : public foo_base, public bar
{
public:
    foobar() { }
    virtual ~foobar() { std::cerr << "virtual foobar::~foobar()" << std::endl; }

    virtual void print()
    {
        std::cerr << "one: " << one << " two: " << two << " three: "
                  << three << " four: " << four << " five: " << five
                  << std::endl;
    }
};

int main()
{
    foo_base* fb = new foobar();

    fb->print();
    delete fb;

    std::cerr.flush();

    return 0;
}
{code}

Output from GCC 4.5.0, SunPro C++ 12.2 with the default libCstd, SunPro C++ 
12.2 with stlport, Pathscale 4.0.12.1:

{noformat}
[steleman@darthvader][/src/steleman/programming/stdcxx-upstream-patches/jira-patches][02/06/2012
 18:48:56][2229]>> ./test_non_virtual_gcc 
one: 0 two: 1 three: 2 four: 3 five: 4
foo_base::~foo_base()
[steleman@darthvader][/src/steleman/programming/stdcxx-upstream-patches/jira-patches][02/06/2012
 18:50:46][2230]>> ./test_non_virtual_cstd
one: 0 two: 1 three: 2 four: 3 five: 4
foo_base::~foo_base()
[steleman@darthvader][/src/steleman/programming/stdcxx-upstream-patches/jira-patches][02/06/2012
 18:50:56][2231]>> ./test_non_virtual_stlport
one: 0 two: 1 three: 2 four: 3 five: 4
foo_base::~foo_base()
[steleman@darthvader][/src/steleman/programming/stdcxx-upstream-patches/jira-patches][02/06/2012
 18:51:00][2232]>> ./test_non_virtual_pathscale
one: 0 two: 1 three: 2 four: 3 five: 4
foo_base::~foo_base()
{noformat}

Do we leak? Yes, we do.

{noformat}
[steleman@darthvader][/src/steleman/programming/stdcxx-upstream-patches/jira-patches][02/06/2012
 18:51:05][2233]>> ./test_virtual_gcc
one: 0 two: 1 three: 2 four: 3 five: 4
virtual foobar::~foobar()
virtual bar::~bar()
virtual foo_base::~foo_base()
[steleman@darthvader][/src/steleman/programming/stdcxx-upstream-patches/jira-patches][02/06/2012
 18:51:10][2234]>> ./test_virtual_cstd
one: 0 two: 1 three: 2 four: 3 five: 4
virtual foobar::~foobar()
virtual bar::~bar()
virtual foo_base::~foo_base()
[steleman@darthvader][/src/steleman/programming/stdcxx-upstream-patches/jira-patches][02/06/2012
 18:51:14][2235]>> ./test_virtual_stlport
one: 0 two: 1 three: 2 four: 3 five: 4
virtual foobar::~foobar()
virtual bar::~bar()
virtual foo_base::~foo_base()
[steleman@darthvader][/src/steleman/programming/stdcxx-upstream-patches/jira-patches][02/06/2012
 18:51:18][2236]>> ./test_virtual_pathscale
one: 0 two: 1 three: 2 four: 3 five: 4
virtual foobar::~foobar()
virtual bar::~bar()
virtual foo_base::~foo_base()
{noformat}

Do we leak? No, we don't.


                
> 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