Uploaded image for project: 'C++ Standard Library'
  1. C++ Standard Library
  2. STDCXX-802

[HP aCC 6.16] bad codegen on ud ctor and factory function

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: External
    • Labels:
      None
    • Environment:

      aCC: HP C/aC++ B3910B A.06.16 [Nov 26 2007]

    • Severity:
      Runtime Error

      Description

      -------- 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 <sebor@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

      $ 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)
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                sebor Martin Sebor
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated: