#include <bits/stdc++.h>
using namespace std;
template <typename T>
const char *f(T x)
{
// type name
return typeid(x).name();
}
int main()
{
auto t1 = -2147483647 - 1;
auto t2 = -2147483648;
auto t3 = -9223372036854775807;
auto t4 = -9223372036854775808;
int a;
long b;
long long c;
unsigned long long d;
__int128 e;
// cout << t1 << " " << t2 << " " << t3 << " " << t4 << endl;
// if t4 is __int128 it will CE
cout << f(t1) << " " << f(t2) << " " << f(t3) << " " << f(t4) << endl;
cout << f(a) << " " << f(b) << " " << f(c) << " " << f(d) << " " << f(e) << endl;
return 0;
}
该程序在本机的输出:
i l l n
i l x y n
但是报了一个 warning:
/home/ppip/codes/cz.cpp:14:16: warning: integer constant is so large that it is unsigned
14 | auto t4 = -9223372036854775808;
| ^~~~~~~~~~~~~~~~~~~
(还有一堆 uninitialized 就不写了)
但是由输出,t4 被视为 __int128
咋搞的捏