-
- Downloads
c: Update nullptr_t comparison checks
WG14 has agreed to allow equality comparisons between pointers and nullptr_t values that are not null pointer constants (this was previously an exceptional case where such nullptr_t values were handled differently from null pointer constants; other places in the standard allowed nullptr_t values, whether or not those values are null pointer constants, in the same contexts as null pointer constants); see the wording at the end of N3077. Update GCC's implementation to match this change. There are also changes to allow null pointer constants of integer or pointer type to be converted to nullptr_t (by assignment, cast or conversion as if by assignment), which I'll deal with separately. Bootstrapped with no regressions for x86_64-pc-linux-gnu. gcc/c/ * c-typeck.cc (build_binary_op): Allow comparisons between pointers and nullptr_t values that are not null pointer constants. gcc/testsuite/ * gcc.dg/c2x-constexpr-3.c: Do not expect comparison of nullptr_t and pointer to be disallowed. * gcc.dg/c2x-nullptr-1.c: Test comparisons of nullptr_t and pointers are allowed. * gcc.dg/c2x-nullptr-3.c: Do not test that comparisons of nullptr_t and pointers are disallowed.
Showing
- gcc/c/c-typeck.cc 6 additions, 2 deletionsgcc/c/c-typeck.cc
- gcc/testsuite/gcc.dg/c2x-constexpr-3.c 0 additions, 1 deletiongcc/testsuite/gcc.dg/c2x-constexpr-3.c
- gcc/testsuite/gcc.dg/c2x-nullptr-1.c 17 additions, 0 deletionsgcc/testsuite/gcc.dg/c2x-nullptr-1.c
- gcc/testsuite/gcc.dg/c2x-nullptr-3.c 0 additions, 15 deletionsgcc/testsuite/gcc.dg/c2x-nullptr-3.c
Loading
Please register or sign in to comment