|
1119 | 1119 | \rSec2[diff.cpp03.language.support]{\ref{language.support}:
|
1120 | 1120 | language support library}
|
1121 | 1121 |
|
1122 |
| -\diffref{new.delete.single} |
1123 |
| -\change Linking \tcode{new} and \tcode{delete} operators. |
1124 |
| -\rationale The two throwing single-object signatures of \tcode{operator new} and |
1125 |
| -\tcode{operator delete} are now specified to form the base functionality for |
1126 |
| -the other operators. This clarifies that replacing just these two signatures |
1127 |
| -changes others, even if they are not explicitly changed. |
1128 |
| -\effect |
1129 |
| -Valid \CppIII{} code that replaces global \tcode{new} or \tcode{delete} |
1130 |
| -operators may execute differently in this International Standard. For |
1131 |
| -example, the following program should write \tcode{"custom deallocation"} twice, |
1132 |
| -once for the single-object delete and once for the array delete. |
1133 |
| - |
1134 |
| -\begin{codeblock} |
1135 |
| -#include <cstdio> |
1136 |
| -#include <cstdlib> |
1137 |
| -#include <new> |
1138 |
| - |
1139 |
| -void* operator new(std::size_t size) throw(std::bad_alloc) { |
1140 |
| - return std::malloc(size); |
1141 |
| -} |
1142 |
| - |
1143 |
| -void operator delete(void* ptr) throw() { |
1144 |
| - std::puts("custom deallocation"); |
1145 |
| - std::free(ptr); |
1146 |
| -} |
1147 |
| - |
1148 |
| -int main() { |
1149 |
| - int* i = new int; |
1150 |
| - delete i; // single-object delete |
1151 |
| - int* a = new int[3]; |
1152 |
| - delete [] a; // array delete |
1153 |
| -} |
1154 |
| -\end{codeblock} |
1155 |
| - |
1156 | 1122 | \diffref{new.delete.single}
|
1157 | 1123 | \change \tcode{operator new} may throw exceptions other than
|
1158 | 1124 | \tcode{std::bad_alloc}.
|
|
1161 | 1127 | Valid \CppIII{} code that assumes that global \tcode{operator new} only
|
1162 | 1128 | throws \tcode{std::bad_alloc} may execute differently in this International
|
1163 | 1129 | Standard.
|
| 1130 | +Valid \CppIII{} code that replaces the global replaceable \tcode{operator new} |
| 1131 | +is ill-formed in this International Standard, |
| 1132 | +because the exception specification of \tcode{throw(std::bad_alloc)} |
| 1133 | +was removed. |
1164 | 1134 |
|
1165 | 1135 | \rSec2[diff.cpp03.diagnostics]{\ref{diagnostics}: diagnostics library}
|
1166 | 1136 |
|
|
0 commit comments