| 3 | constexpr int g_conexprTempA = 4; |
| 4 | |
| 5 | int main(void) |
| 6 | { |
| 7 | int tempA = 4; |
| 8 | const int conTempA = 4; |
| 9 | constexpr int conexprTempA = 4; |
| 10 | |
| 11 | /*1.正常运行,编译通过*/ |
| 12 | const int *conptrA = &tempA; |
| 13 | const int *conptrB = &conTempA; |
| 14 | const int *conptrC = &conexprTempA; |
| 15 | /*2.局部变量的地址要运行时才能确认,故不能在编译期决定,编译不过*/ |
| 16 | //constexpr int *conexprPtrA = &tempA; |
| 17 | //constexpr int *conexprPtrB = &conTempA |
| 18 | //constexpr int *conexprPtrC = &conexprTempA; |
| 19 | /*3.第一个通过,后面两个不过,因为constexpr int *所限定的是指针是常量,故不能将常量的地址赋给顶层const*/ |
| 20 | constexpr int *conexprPtrD = &g_tempA; |
| 21 | constexpr int *conexprPtrE = &g_conTempA |
| 22 | constexpr int *conexprPtrF = &g_conexprTempA; |
| 23 | /*4.局部变量的地址要运行时才能确认,故不能在编译期决定,编译不过*/ |
| 24 | //constexpr const int *conexprConPtrA = &tempA; |
| 25 | //constexpr const int *conexprConPtrB = &conTempA; |
| 26 | //constexpr const int *conexprConPtrC = &conexprTempA; |
| 27 | /*5.正常运行,编译通过*/ |
| 28 | constexpr const int *conexprConPtrD = &g_tempA; |
| 29 | constexpr const int *conexprConPtrE = &g_conTempA; |
| 30 | constexpr const int *conexprConPtrF = &g_conexprTempA; |
| 31 | |
| 32 | return 0; |
| 33 | } |
nothing calls this directly
no outgoing calls
no test coverage detected