[
https://issues.apache.org/jira/browse/STDCXX-802?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12583165#action_12583165
]
Martin Sebor commented on STDCXX-802:
-------------------------------------
This is interesting: it looks as though the bug is triggered by the
{{const}}-ness of the {{B}} pointer:
{noformat}
$ cat t.cpp && aCC -AA -V t.cpp && ./a.out || aCC -AA -Dconst= -V t.cpp &&
./a.out
struct B { ~B () { } };
B* f ();
void g (const B*);
to
struct A {
const B* b;
A (): b (f ()) { }
~A () { g (b); }
};
int main () {
A a;
}
B* f () { return new B [1]; }
void g (const B *b) { delete[] b; }
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)
aCC: HP C/aC++ B3910B A.06.16 [Nov 26 2007]
ld: 92453-07 linker ld HP Itanium(R) B.12.41 IPF/IPF
$
{noformat}
> [HP aCC 6.16] bad codegen on ud ctor and factory function
> ---------------------------------------------------------
>
> 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 <[EMAIL PROTECTED]>
> Organization: Rogue Wave Software, Inc.
> To: [EMAIL PROTECTED]
> 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.