comparison gcc/testsuite/g++.dg/cpp0x/nullptr04.C @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 1830386684a0
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
1 // { dg-do compile { target c++11 } }
2
3 // Test cast to int
4
5 __extension__ typedef __INTPTR_TYPE__ intptr_t;
6
7 const int n4 = static_cast<const int>(nullptr); // { dg-error "invalid static_cast " }
8 const short int n5 = reinterpret_cast<short int>(nullptr); // { dg-error "loses precision" }
9 const intptr_t n6 = reinterpret_cast<intptr_t>(nullptr);
10 const intptr_t n7 = (intptr_t)nullptr;
11
12 decltype(nullptr) mynull = 0;
13 const int n8 = static_cast<const int>(mynull); // { dg-error "invalid static_cast " }
14 const short int n9 = reinterpret_cast<short int>(mynull); // { dg-error "loses precision" }
15 const intptr_t n10 = reinterpret_cast<intptr_t>(mynull);
16 const intptr_t n11 = (intptr_t)mynull;