| 1 |
// This test fails on VxWorks in kernel mode because it depends on the |
| 2 |
// library version of "::operator new[]" calling the "::operator new" |
| 3 |
// defined in this module. This doesn't work because the library version |
| 4 |
// of "::operator new[]" is built into the kernel itself; library relocations |
| 5 |
// are resolved when the kernel is linked. |
| 6 |
// { dg-do run { xfail { powerpc-ibm-aix* || vxworks_kernel } } } |
| 7 |
// { dg-options "-flat_namespace" { target *-*-darwin[67]* } } |
| 8 |
// Avoid use of none-overridable new/delete operators in shared |
| 9 |
// { dg-options "-static" { target *-*-mingw* } } |
| 10 |
// { dg-skip-if "requires hosted libstdc++ for stdlib malloc" { ! hostedlib } } |
| 11 |
|
| 12 |
// GROUPS passed operator-new |
| 13 |
#include <stdio.h> |
| 14 |
#include <stdlib.h> |
| 15 |
#include <new> |
| 16 |
|
| 17 |
int pass = 0; |
| 18 |
|
| 19 |
void *operator new(size_t sz) |
| 20 |
#if __cplusplus <= 199711L |
| 21 |
throw (std::bad_alloc) |
| 22 |
#endif |
| 23 |
{ |
| 24 |
|
| 25 |
void *p; |
| 26 |
|
| 27 |
pass = 1; |
| 28 |
p = malloc(sz); |
| 29 |
return p; |
| 30 |
} |
| 31 |
|
| 32 |
class A { |
| 33 |
public: |
| 34 |
A() {} |
| 35 |
~A() {} |
| 36 |
|
| 37 |
int a; |
| 38 |
int b; |
| 39 |
}; |
| 40 |
|
| 41 |
|
| 42 |
int main() |
| 43 |
{ |
| 44 |
A *bb = new A[10]; |
| 45 |
delete [] bb; |
| 46 |
|
| 47 |
if (pass) |
| 48 |
printf ("PASS\n"); |
| 49 |
else |
| 50 |
{ printf ("FAIL\n"); return 1; } |
| 51 |
} |