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