| 1 |
// DR 1512 |
| 2 |
// PR c++/87699 |
| 3 |
// { dg-do compile { target c++11 } } |
| 4 |
|
| 5 |
/* Relational comparisons between null pointer constants and pointers are now |
| 6 |
ill-formed. */ |
| 7 |
|
| 8 |
void |
| 9 |
f (char *p) |
| 10 |
{ |
| 11 |
if (p > 0) { } // { dg-error "ordered comparison of pointer with integer zero" } |
| 12 |
if (p >= 0) { } // { dg-error "ordered comparison of pointer with integer zero" } |
| 13 |
if (p < 0) { } // { dg-error "ordered comparison of pointer with integer zero" } |
| 14 |
if (p <= 0) { } // { dg-error "ordered comparison of pointer with integer zero" } |
| 15 |
if (p > nullptr) { } // { dg-error "ordered comparison of pointer with integer zero" } |
| 16 |
if (p >= nullptr) { } // { dg-error "ordered comparison of pointer with integer zero" } |
| 17 |
if (p < nullptr) { } // { dg-error "ordered comparison of pointer with integer zero" } |
| 18 |
if (p <= nullptr) { } // { dg-error "ordered comparison of pointer with integer zero" } |
| 19 |
} |
| 20 |
|
| 21 |
void |
| 22 |
f2 (char *p) |
| 23 |
{ |
| 24 |
if (0 > p) { } // { dg-error "ordered comparison of pointer with integer zero" } |
| 25 |
if (0 >= p) { } // { dg-error "ordered comparison of pointer with integer zero" } |
| 26 |
if (0 < p) { } // { dg-error "ordered comparison of pointer with integer zero" } |
| 27 |
if (0 <= p) { } // { dg-error "ordered comparison of pointer with integer zero" } |
| 28 |
if (nullptr > p) { } // { dg-error "ordered comparison of pointer with integer zero" } |
| 29 |
if (nullptr >= p) { } // { dg-error "ordered comparison of pointer with integer zero" } |
| 30 |
if (nullptr < p) { } // { dg-error "ordered comparison of pointer with integer zero" } |
| 31 |
if (nullptr <= p) { } // { dg-error "ordered comparison of pointer with integer zero" } |
| 32 |
} |