[survey] LWG issue 206

H

Howard Hinnant

Hello,

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

http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#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_symbol_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("custom allocation\n");
if (size == 0)
size = 1;
void*p = std::malloc(size);
if (p == 0)
throw std::bad_alloc();
return p;
}

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

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

David Harmon

On Fri, 10 Nov 2006 19:31:05 GMT in comp.lang.c++, Howard Hinnant
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
 
D

David Harmon

On Fri, 10 Nov 2006 19:31:05 GMT in comp.lang.c++, Howard Hinnant
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+kernel32/noi;

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

Alexey Sarytchev

Howard said:
Hello,

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

http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#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
 
R

Rahtgaz

David Harmon said:
On Fri, 10 Nov 2006 19:31:05 GMT in comp.lang.c++, Howard Hinnant


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
 
D

David Harmon

On Fri, 10 Nov 2006 21:11:28 GMT in comp.lang.c++, Alexey Sarytchev
$ 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.
 
H

Howard Hinnant

Howard Hinnant said:
Hello,

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

http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#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:

http://home.twcny.rr.com/hinnant/cpp_extensions/issue206.html

Comments, critiques on the paper are also welcome.

Thanks,
Howard
 
V

VJ

Howard said:
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_symbol_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)
 
A

Alexey Sarytchev

David said:
On Fri, 10 Nov 2006 21:11:28 GMT in comp.lang.c++, Alexey Sarytchev

...

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("custom allocation\n");
if (size == 0)
size = 1;
void*p = std::malloc(size);
if (p == 0)
throw std::bad_alloc();
return p;
}

void operator delete(void* ptr) throw()
{
std::printf("custom 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
 
R

Roland Pibinger

On Fri, 10 Nov 2006 19:31:05 GMT in comp.lang.c++, Howard Hinnant
wrote,

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

Why not just #include the necessary file?

Best wishes,
Roland Pibinger
 
A

Alexey Sarytchev

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
 
M

Marcus Kwok

David Harmon said:
On Fri, 10 Nov 2006 19:31:05 GMT in comp.lang.c++, Howard Hinnant


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,wchar_t /GR /Za /Op- hh.cpp)
 
H

Howard Hinnant

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,wchar_t /GR /Za /Op- hh.cpp)


Thanks, I've changed my reference to:

* Microsoft Visual Studio, all recent versions

http://home.twcny.rr.com/hinnant/cpp_extensions/issue206.html

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

-Howard
 
D

David Harmon

On Mon, 13 Nov 2006 15:26:23 GMT in comp.lang.c++, (e-mail address removed)
(Roland Pibinger) wrote,
Why not just #include the necessary file?

Which file would that be?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top