
When casting a 0 to a pointer type, the IsNullPtr flag was always set to false, leading to weird results like a pointer with value 0 that isn't a null pointer. This caused ```c++ struct B { const int *p;}; template<B> void f() {} template void f<B{nullptr}>(); template void f<B{fold(reinterpret_cast<int*>(0))}>(); ``` to be valid code, since nullptr and (int*)0 aren't equal. This seems weird and GCC doesn't behave like this.
10 lines
255 B
Plaintext
10 lines
255 B
Plaintext
// RUN: %clang_cc1 -triple amdgcn -cl-std=clc++ -verify %s
|
|
|
|
// expected-no-diagnostics
|
|
|
|
#define fold(x) (__builtin_constant_p(x) ? (x) : (x))
|
|
static_assert(nullptr != fold(reinterpret_cast<private int*>(0)));
|
|
|
|
static_assert(nullptr == (private int *)0);
|
|
|