You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@stdcxx.apache.org by "Martin Sebor (JIRA)" <ji...@apache.org> on 2008/03/28 20:26:25 UTC

[jira] Commented: (STDCXX-802) [HP aCC 6.16] bad codegen on ud operator new and ud ctor]

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

Martin Sebor commented on STDCXX-802:
-------------------------------------

The test case can be further simplified:

{noformat}
$ cat t.cpp && aCC -AA -V t.cpp && ./a.out 
template <class T>
struct A {
    const T* x;
    A (): x (T::foo ()) { }
    ~A () { delete[] x; }
};

struct B {
    ~B () { }
    static B* foo ();
};

template <class T> T* foo (T*) { return new T [1]; }
B* B::foo () { return ::foo ((B*)0); }

int main () {
    A<B> td;
}
aCC: HP C/aC++ B3910B A.06.16 [Nov 26 2007]
ld: 92453-07 linker ld HP Itanium(R) B.12.41  IPF/IPF
Segmentation fault (core dumped)
{noformat}

> [HP aCC 6.16] bad codegen on ud operator new and ud ctor]
> ---------------------------------------------------------
>
>                 Key: STDCXX-802
>                 URL: https://issues.apache.org/jira/browse/STDCXX-802
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: External
>         Environment: aCC: HP C/aC++ B3910B A.06.16 [Nov 26 2007]
>            Reporter: Martin Sebor
>
> -------- Original Message --------
> Subject: aCC 6.16 bad codegen on ud operator new and ud ctor
> Date: Fri, 28 Mar 2008 13:13:03 -0600
> From: Martin Sebor <se...@roguewave.com>
> Organization: Rogue Wave Software, Inc.
> To: acxx@cup.hp.com
> This bug has been causing a bunch of failures in our test
> suite since 6.0. The user-defined dtor in class B triggers
> it. Changing the number of allocated elements from 2 to 1
> causes a SEGV.
> Martin
> {noformat}
> $ cat t.cpp && aCC -AA -V t.cpp && ./a.out
> #include <cassert>
> #include <cstdio>
> #include <cstdlib>
> #include <new>
> void *palloc;
> void *pfree;
> void* operator new (std::size_t n) throw (std::bad_alloc) {
>     void* const ptr = std::malloc (n);
>     std::fprintf (stderr, "operator new (%zu) ==> %p\n", n, ptr);
>     return ptr;
> }
> void operator delete (void *ptr) throw () {
>     std::fprintf (stderr, "operator delete (%p)\n", ptr);
>     std::free (ptr);
> }
> void* operator new[] (std::size_t n) throw (std::bad_alloc) {
>     void* const ptr = std::malloc (n);
>     std::fprintf (stderr, "operator new[] (%zu) ==> %p\n", n, ptr);
>     return palloc = ptr;
> }
> void operator delete[] (void *ptr) throw () {
>     std::fprintf (stderr, "operator delete[] (%p)\n", ptr);
>     std::free (pfree = ptr);
> }
> template <class T>
> struct A {
>     const T* x;
>     A (): x (T::foo ()) { }
>     ~A () { delete[] x; }
> };
> struct B {
>     ~B () { }
>     static B* foo ();
> };
> template <class T> T* foo (T*) { return new T [2]; }
> B* B::foo () { return ::foo ((B*)0); }
> int main () {
>     { A<B> td; }
>     assert (palloc == pfree);
> }
> aCC: HP C/aC++ B3910B A.06.16 [Nov 26 2007]
> ld: 92453-07 linker ld HP Itanium(R) B.12.41  IPF/IPF
> operator new (16) ==> 400124b0
> operator new[] (6) ==> 40012510
> operator delete[] (40012514)
> Assertion failed: palloc == pfree, file t.cpp, line 48
> ABORT instruction (core dumped)
> {noformat}

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