[调查] LWG问题206 [英] [survey] LWG issue 206
问题描述
你好,
我正在写一篇关于LWG问题206的简短论文:
http://www.open-std.org/jtc1/sc22/wg。 ..ctive.html#206
的结果,以及产生这些结果的编译器(包括版本)
。为了让球滚动,这里有结果
我知道:
CodeWarrior Pro 7-10:
自定义分配
自定义分配
自定义分配
自定义释放
gcc 4.0 .1在Mac OS X *上:
自定义分配
自定义释放
自定义分配
自定义释放
*对于gcc / Mac上面的结果我不得不将以下行添加到
关于副作用的程序我是这里不解决:
__attribute __((__ weak __,__ visibility __(" default")))int
dummy_weak_symbol_for_new;
以下是测试。提前谢谢。
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 );
如果(p == 0)
抛出std :: bad_alloc();
返回p;
}
void operator delete(void * ptr)throw()
{
std :: printf(" custom deallocation \ n");
std :: free(ptr);
}
int main()
{
int * i = new int;
删除i;
int * a = new int [3 ];
删除[] a;
}
Hello,
I''m writing a brief paper on LWG issue 206:
http://www.open-std.org/jtc1/sc22/wg...ctive.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;
}
推荐答案
11月10日星期五2006 19:31:05 GMT in comp.lang.c ++,Howard Hinnant
< ho ************ @ gmail.comwrote,
On Fri, 10 Nov 2006 19:31:05 GMT in comp.lang.c++, Howard Hinnant
<ho************@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位C / C ++优化编译器版本13.10.3077
80x86
版权所有(C)Microsoft Corporation 1984-2002。保留所有权利。
h.cpp
Microsoft(R)增量链接器版本7.10.3077
版权所有(C)Microsoft公司。保留所有权利。
/out:h.exe
h.obj
C:\ USR \ temp> h
自定义分配
自定义释放
自定义分配
自定义释放
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
2006年11月10日星期五19:31:05 GMT in comp.lang.c ++,Howard Hinnant
< ho **** ********@gmail.com写的,
On Fri, 10 Nov 2006 19:31:05 GMT in comp.lang.c++, Howard Hinnant
<ho************@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
数字火星编译器版本8.38n
版权所有( C)数字火星2000-2003。保留所有权利。
由Walter Bright撰写 www.digitalmars.com
C:\ USR \ temp> dmc -Ae h.cpp
{
^
h.cpp(6):错误:异常规范必须完全匹配函数的每个
声明
{
^
h.cpp(17):错误:异常规范必须完全匹配函数的每个
声明
--- errorlevel 1
分别更改这些行后:
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
自定义分配
自定义释放
自定义释放
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
Howard Hinnant写道:
Howard Hinnant wrote:
您好,
我正在撰写关于LWG问题206的简短论文:
http:/ /www.open-std.org/jtc1/sc22/wg...ctive.html#206
几家供应商的做法。我要求志愿者在短程序后发布
的结果,以及产生这些结果的编译器(包括版本)
。为了得到滚动,这里是结果
Hello,
I''m writing a brief paper on LWG issue 206:
http://www.open-std.org/jtc1/sc22/wg...ctive.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
AIX 5.3上的IBM VisualAge C ++ 7.0:
IBM VisualAge C++ 7.0 on AIX 5.3:
这篇关于[调查] LWG问题206的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!