[survey] LWG issue 206

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Howard Hinnant

    [survey] LWG issue 206

    Hello,

    I'm writing a brief paper on LWG issue 206:



    It would help me immensely if I knew more about the current practice of
    several vendors. I am asking for volunteers to post the results of the
    following short program, along with the compiler (including version)
    which produced those results. To get the ball rolling, here are results
    I'm aware of:

    CodeWarrior Pro 7-10:

    custom allocation
    custom deallocation
    custom allocation
    custom deallocation

    gcc 4.0.1 on Mac OS X*:

    custom allocation
    custom deallocation
    custom allocation
    custom deallocation

    * For the above results on gcc/Mac I had to add the following line to
    the program which concerns a side issue I'm not addressing herein:

    __attribute__(( __weak__, __visibility__( "default")) ) int
    dummy_weak_symb ol_for_new;

    Below is the test. Thank you in advance.

    Howard Hinnant

    ----------------

    #include <cstdio>
    #include <cstdlib>
    #include <new>

    void* operator new(std::size_t size) throw(std::bad_ alloc)
    {
    std::printf("cu stom allocation\n");
    if (size == 0)
    size = 1;
    void*p = std::malloc(siz e);
    if (p == 0)
    throw std::bad_alloc( );
    return p;
    }

    void operator delete(void* ptr) throw()
    {
    std::printf("cu stom deallocation\n" );
    std::free(ptr);
    }

    int main()
    {
    int* i = new int;
    delete i;
    int* a = new int[3];
    delete [] a;
    }
  • David Harmon

    #2
    Re: [survey] LWG issue 206

    On Fri, 10 Nov 2006 19:31:05 GMT in comp.lang.c++, Howard Hinnant
    <howard.hinnant @gmail.comwrote ,
    >I am asking for volunteers to post the results of the
    >following short program, along with the compiler (including version)
    >which produced those results.
    C:\USR\temp>cl /EHsc h.cpp
    Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077 for
    80x86
    Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.

    h.cpp
    Microsoft (R) Incremental Linker Version 7.10.3077
    Copyright (C) Microsoft Corporation. All rights reserved.

    /out:h.exe
    h.obj

    C:\USR\temp>h
    custom allocation
    custom deallocation
    custom allocation
    custom deallocation

    Comment

    • David Harmon

      #3
      Re: [survey] LWG issue 206

      On Fri, 10 Nov 2006 19:31:05 GMT in comp.lang.c++, Howard Hinnant
      <howard.hinnant @gmail.comwrote ,
      >I am asking for volunteers to post the results of the
      >following short program, along with the compiler (including version)
      >which produced those results.
      C:\USR\temp>dmc
      Digital Mars Compiler Version 8.38n
      Copyright (C) Digital Mars 2000-2003. All Rights Reserved.
      Written by Walter Bright www.digitalmars.com

      C:\USR\temp>dmc -Ae h.cpp
      {
      ^
      h.cpp(6) : Error: Exception specifications must match exactly for each
      declaration of a function
      {
      ^
      h.cpp(17) : Error: Exception specifications must match exactly for each
      declaration of a function
      --- errorlevel 1

      After changing those lines to respectively:
      void* operator new(std::size_t size) // throw(std::bad_ alloc)
      void operator delete(void* ptr) // throw()

      C:\USR\temp>dmc -Ae h.cpp
      link h,,,user32+kern el32/noi;

      C:\USR\temp>h
      custom allocation
      custom deallocation
      custom deallocation


      Comment

      • Alexey Sarytchev

        #4
        Re: [survey] LWG issue 206

        Howard Hinnant wrote:
        Hello,
        >
        I'm writing a brief paper on LWG issue 206:
        >

        >
        It would help me immensely if I knew more about the current practice of
        several vendors. I am asking for volunteers to post the results of the
        following short program, along with the compiler (including version)
        which produced those results. To get the ball rolling, here are results
        IBM VisualAge C++ 7.0 on AIX 5.3:

        $ xlC qq.cpp
        $ ./a.out
        custom allocation
        custom deallocation


        HP ANSI C++ B3910B A.03.56 on HP-UX 11.11 (PARISC)

        $ aCC -AA qq.cpp
        $ ./a.out
        custom allocation
        custom deallocation


        HP aC++/ANSI C B3910B A.06.00 [Aug 25 2004] on HP-UX 11.23 (Itanium)

        $ aCC -AA qq.cpp && ./a.out
        custom allocation
        custom allocation
        custom deallocation

        Sun C++ 5.8 2005/10/13 on Solaris 8 (SPARC)

        $ CC qq.cpp && ./a.out
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom deallocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom deallocation
        custom allocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom allocation
        custom allocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom allocation
        custom allocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom allocation
        custom allocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom allocation
        custom allocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom allocation
        custom allocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom allocation
        custom allocation
        custom deallocation
        custom deallocation
        custom deallocation


        GCC 4.0.2 on Solaris 8 (SPARC)
        $ g++ qq.cpp && ./a.out
        custom allocation
        custom deallocation
        custom allocation
        custom deallocation

        $ CC -V
        CC: Forte Developer 7 C++ 5.4 2002/03/09 on Solaris 9 (SPARC)
        $ CC qq.cpp && ./a.out
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom deallocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom allocation
        custom deallocation
        custom allocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation
        custom deallocation


        GCC 3.4.3 on Solaris 9 (SPARC)

        $ g++ qq.cpp && ./a.out
        custom allocation
        custom deallocation
        custom allocation
        custom deallocation

        GCC 3.4.0 on RedHat Enterprise Linux AS release 3

        $ g++ qq.cpp && ./a.out
        custom allocation
        custom deallocation
        custom allocation
        custom deallocation

        Regards,
        Alexey Sarytchev

        Comment

        • Rahtgaz

          #5
          Re: [survey] LWG issue 206

          In article <4567e0d3.50333 906@news.west.e arthlink.net>, David Harmon
          says...
          On Fri, 10 Nov 2006 19:31:05 GMT in comp.lang.c++, Howard Hinnant
          <howard.hinnant @gmail.comwrote ,
          I am asking for volunteers to post the results of the
          following short program, along with the compiler (including version)
          which produced those results.
          >
          C:\USR\temp>dmc
          Digital Mars Compiler Version 8.38n
          Copyright (C) Digital Mars 2000-2003. All Rights Reserved.
          Written by Walter Bright www.digitalmars.com
          g++ (GCC) 3.4.5 (mingw special)

          custom allocation
          custom deallocation
          custom allocation
          custom deallocation

          Comment

          • David Harmon

            #6
            Re: [survey] LWG issue 206

            On Fri, 10 Nov 2006 21:11:28 GMT in comp.lang.c++, Alexey Sarytchev
            <alx_s@hotmail. comwrote,
            >$ CC qq.cpp && ./a.out
            >custom allocation
            >custom allocation
            >custom allocation
            >custom allocation
            >custom allocation
            >custom allocation
            >custom allocation
            >custom allocation
            >custom allocation
            >custom allocation
            >custom allocation
            >custom allocation
            >custom allocation
            ....

            Awesome. Perhaps you would add
            cout << "Begin\n";
            and
            cout << "\End\n";
            in main() for clarification.

            Comment

            • Howard Hinnant

              #7
              Re: [survey] LWG issue 206

              In article
              <howard.hinna nt-F0F240.14310510 112006@syrcnyrd rs-02-ge0.nyroc.rr.co m>,
              Howard Hinnant <howard.hinnant @gmail.comwrote :
              Hello,
              >
              I'm writing a brief paper on LWG issue 206:
              >

              >
              It would help me immensely if I knew more about the current practice of
              several vendors.
              Thanks to those who helped in the survey. If anyone has more data to
              add (not already included in the paper), I will gladly accept it.

              I've put the current draft of the paper up at:



              Comments, critiques on the paper are also welcome.

              Thanks,
              Howard

              Comment

              • VJ

                #8
                Re: [survey] LWG issue 206

                Howard Hinnant wrote:
                >
                CodeWarrior Pro 7-10:
                >
                custom allocation
                custom deallocation
                custom allocation
                custom deallocation
                >
                gcc 4.0.1 on Mac OS X*:
                >
                custom allocation
                custom deallocation
                custom allocation
                custom deallocation
                >
                * For the above results on gcc/Mac I had to add the following line to
                the program which concerns a side issue I'm not addressing herein:
                >
                __attribute__(( __weak__, __visibility__( "default")) ) int
                dummy_weak_symb ol_for_new;
                >
                Below is the test. Thank you in advance.
                >

                custom allocation
                custom deallocation
                custom allocation
                custom deallocation

                gcc version 4.0.2 20051125 (Red Hat 4.0.2-8)

                Comment

                • Alexey Sarytchev

                  #9
                  Re: [survey] LWG issue 206

                  David Harmon wrote:
                  On Fri, 10 Nov 2006 21:11:28 GMT in comp.lang.c++, Alexey Sarytchev
                  <alx_s@hotmail. comwrote,
                  >$ CC qq.cpp && ./a.out
                  >custom allocation
                  >custom allocation
                  >custom allocation
                  >custom allocation
                  >custom allocation
                  >custom allocation
                  >custom allocation
                  >custom allocation
                  >custom allocation
                  >custom allocation
                  >custom allocation
                  >custom allocation
                  >custom allocation
                  ...
                  >
                  Awesome. Perhaps you would add
                  cout << "Begin\n";
                  and
                  cout << "\End\n";
                  in main() for clarification.
                  >
                  $ CC -V
                  CC: Sun C++ 5.8 2005/10/13
                  $ CC qq.cpp && ./a.out
                  custom allocation
                  custom allocation
                  custom allocation
                  custom allocation
                  custom allocation
                  custom allocation
                  custom allocation
                  custom allocation
                  custom allocation
                  custom allocation
                  custom allocation
                  custom allocation
                  custom allocation
                  custom allocation
                  custom allocation
                  custom allocation
                  custom allocation
                  custom allocation
                  custom allocation
                  custom allocation
                  custom deallocation
                  custom allocation
                  custom allocation
                  custom allocation
                  custom allocation
                  custom allocation
                  custom allocation
                  custom allocation
                  custom allocation
                  custom allocation
                  custom allocation
                  custom allocation
                  Begin
                  custom allocation
                  custom deallocation
                  custom allocation
                  custom deallocation
                  End
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom allocation
                  custom allocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom allocation
                  custom allocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom allocation
                  custom allocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom allocation
                  custom allocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom allocation
                  custom allocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  custom allocation
                  custom allocation
                  custom deallocation
                  custom deallocation
                  custom deallocation
                  $

                  for the next program:
                  =============== = cut =============== ======
                  #include <cstdio>
                  #include <cstdlib>
                  #include <new>
                  #include <iostream>
                  using namespace std;

                  void* operator new(std::size_t size) throw(std::bad_ alloc)
                  {
                  std::printf("cu stom allocation\n");
                  if (size == 0)
                  size = 1;
                  void*p = std::malloc(siz e);
                  if (p == 0)
                  throw std::bad_alloc( );
                  return p;
                  }

                  void operator delete(void* ptr) throw()
                  {
                  std::printf("cu stom deallocation\n" );
                  std::free(ptr);
                  }

                  int main()
                  {
                  cout << "Begin\n";
                  int* i = new int;
                  delete i;
                  int* a = new int[3];
                  delete [] a;
                  cout << "End\n";
                  }
                  =============== = cut =============== ======

                  Regards,
                  Alexey Sarytchev

                  Comment

                  • Roland Pibinger

                    #10
                    Re: [survey] LWG issue 206

                    On Fri, 10 Nov 2006 20:34:30 GMT, David Harmon wrote:
                    >On Fri, 10 Nov 2006 19:31:05 GMT in comp.lang.c++, Howard Hinnant
                    >wrote,
                    >>I am asking for volunteers to post the results of the
                    >>following short program, along with the compiler (including version)
                    >>which produced those results.
                    >
                    >C:\USR\temp>dm c
                    >Digital Mars Compiler Version 8.38n
                    >Copyright (C) Digital Mars 2000-2003. All Rights Reserved.
                    >Written by Walter Bright www.digitalmars.com
                    >
                    >C:\USR\temp>dm c -Ae h.cpp
                    >{
                    >^
                    >h.cpp(6) : Error: Exception specifications must match exactly for each
                    >declaration of a function
                    >{
                    >^
                    >h.cpp(17) : Error: Exception specifications must match exactly for each
                    >declaration of a function
                    >--- errorlevel 1
                    >
                    >After changing those lines to respectively:
                    >void* operator new(std::size_t size) // throw(std::bad_ alloc)
                    >void operator delete(void* ptr) // throw()
                    Why not just #include the necessary file?

                    Best wishes,
                    Roland Pibinger

                    Comment

                    • Alexey Sarytchev

                      #11
                      Re: [survey] LWG issue 206

                      Alexey Sarytchev wrote:
                      David Harmon wrote:
                      >On Fri, 10 Nov 2006 21:11:28 GMT in comp.lang.c++, Alexey Sarytchev
                      ><alx_s@hotmail .comwrote,
                      >>$ CC qq.cpp && ./a.out
                      >>custom allocation
                      >>custom allocation
                      >>custom allocation
                      >>custom allocation
                      >>custom allocation
                      >>custom allocation
                      >>custom allocation
                      >>custom allocation
                      >>custom allocation
                      >>custom allocation
                      >>custom allocation
                      >>custom allocation
                      >>custom allocation
                      >...
                      >>
                      >Awesome. Perhaps you would add
                      > cout << "Begin\n";
                      >and cout << "\End\n";
                      >in main() for clarification.
                      I think you will like this:

                      $ aCC -V
                      aCC: HP aC++/ANSI C B3910B A.06.00 [Aug 25 2004]
                      $ aCC -AA qq.cpp && ./a.out
                      custom allocation
                      custom allocation
                      custom allocation
                      custom allocation
                      custom allocation
                      custom allocation
                      custom allocation
                      custom allocation
                      custom allocation
                      custom allocation
                      custom allocation
                      custom deallocation
                      custom allocation
                      custom allocation
                      Begin
                      custom allocation
                      custom deallocation
                      End

                      $ aCC -V
                      aCC: HP ANSI C++ B3910B A.03.56
                      $ aCC -AA qq.cpp && ./a.out
                      custom allocation
                      custom allocation
                      custom allocation
                      custom allocation
                      custom allocation
                      custom allocation
                      custom allocation
                      custom allocation
                      custom allocation
                      custom allocation
                      custom deallocation
                      custom allocation
                      custom allocation
                      Begin
                      custom allocation
                      custom deallocation
                      End


                      Regards,
                      Alexey Sarytchev

                      Comment

                      • Marcus Kwok

                        #12
                        Re: [survey] LWG issue 206

                        David Harmon <source@netcom. comwrote:
                        On Fri, 10 Nov 2006 19:31:05 GMT in comp.lang.c++, Howard Hinnant
                        <howard.hinnant @gmail.comwrote ,
                        >>I am asking for volunteers to post the results of the
                        >>following short program, along with the compiler (including version)
                        >>which produced those results.
                        >
                        C:\USR\temp>cl /EHsc h.cpp
                        Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077 for
                        80x86
                        >
                        custom allocation
                        custom deallocation
                        custom allocation
                        custom deallocation
                        For what it's worth, I get the same results with

                        Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.6030 for 80x86

                        which is the Visual Studio .NET 2003 compiler with SP1 applied, and a
                        stricter set of compile options in terms of standards-compliance
                        (thought most of them shouldn't affect this example):
                        (cl /EHsc /Zc:forScope,wch ar_t /GR /Za /Op- hh.cpp)

                        --
                        Marcus Kwok
                        Replace 'invalid' with 'net' to reply

                        Comment

                        • Howard Hinnant

                          #13
                          Re: [survey] LWG issue 206

                          In article <ejalt0$g29$1@n ews-int2.gatech.edu >,
                          ricecake@gehenn om.invalid (Marcus Kwok) wrote:
                          David Harmon <source@netcom. comwrote:
                          On Fri, 10 Nov 2006 19:31:05 GMT in comp.lang.c++, Howard Hinnant
                          <howard.hinnant @gmail.comwrote ,
                          >I am asking for volunteers to post the results of the
                          >following short program, along with the compiler (including version)
                          >which produced those results.
                          C:\USR\temp>cl /EHsc h.cpp
                          Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077 for
                          80x86

                          custom allocation
                          custom deallocation
                          custom allocation
                          custom deallocation
                          >
                          For what it's worth, I get the same results with
                          >
                          Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.6030 for 80x86
                          >
                          which is the Visual Studio .NET 2003 compiler with SP1 applied, and a
                          stricter set of compile options in terms of standards-compliance
                          (thought most of them shouldn't affect this example):
                          (cl /EHsc /Zc:forScope,wch ar_t /GR /Za /Op- hh.cpp)

                          Thanks, I've changed my reference to:

                          * Microsoft Visual Studio, all recent versions



                          If anyone discovers this is not an accurate characterizatio n, please
                          make some noise.

                          -Howard

                          Comment

                          • David Harmon

                            #14
                            Re: [survey] LWG issue 206

                            On Mon, 13 Nov 2006 15:26:23 GMT in comp.lang.c++, rpbg123@yahoo.c om
                            (Roland Pibinger) wrote,
                            >>After changing those lines to respectively:
                            >>void* operator new(std::size_t size) // throw(std::bad_ alloc)
                            >>void operator delete(void* ptr) // throw()
                            >
                            >Why not just #include the necessary file?
                            Which file would that be?

                            Comment

                            Working...