fork(18) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Fuga
  5. {
  6. public:
  7. int a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16;
  8. int b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16;
  9. int c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16;
  10. int d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,d13,d14,d15,d16;
  11. int e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16;
  12. int f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15,f16;
  13. int g1,g2,g3,g4,g5,g6,g7,g8,g9,g10,g11,g12,g13,g14,g15,g16;
  14. int h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11,h12,h13,h14,h15,h16;
  15. int i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12,i13,i14,i15,i16;
  16. int j1,j2,j3,j4,j5,j6,j7,j8,j9,j10,j11,j12,j13,j14,j15,j16;
  17. int k1,k2,k3,k4,k5,k6,k7,k8,k9,k10,k11,k12,k13,k14,k15,k16;
  18. int l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11,l12,l13,l14,l15,l16;
  19. int m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15,m16;
  20. int n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16;
  21. int o1,o2,o3,o4,o5,o6,o7,o8,o9,o10,o11,o12,o13,o14,o15,o16;
  22. int p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16;
  23. int r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r13,r14,r15,r16;
  24. int s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15,s16;
  25. int t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16;
  26. int u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15,u16;
  27. int v1,v2,v3,v4,v5,v6,v7,v8,v9,v10,v11,v12,v13,v14,v15,v16;
  28. int w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11,w12,w13,w14,w15,w16;
  29. int x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,x16;
  30. int y1,y2,y3,y4,y5,y6,y7,y8,y9,y10,y11,y12,y13,y14,y15,y16;
  31. int z1,z2,z3,z4,z5,z6,z7,z8,z9,z10,z11,z12,z13,z14,z15,z16;
  32. };
  33.  
  34. struct nat {};
  35.  
  36. struct hat {};
  37.  
  38. inline int nat::*bar() { return 0; }
  39.  
  40. inline void *foo() { return 0; }
  41.  
  42. inline int *baz() { return 0; }
  43.  
  44. inline int hat::*hoge() { return 0; }
  45.  
  46. typedef int (Fuga::*FugaInt);
  47.  
  48. int main() {
  49.  
  50. Fuga fuga;
  51.  
  52. int (Fuga::*i1) = &Fuga::a1;
  53. int (Fuga::*i2) = &Fuga::z16;
  54.  
  55. FugaInt i3 = i1;
  56.  
  57. int id = i2 - i1; // bool(i2) - bool(i1) !! cannot get differece address!
  58. // bool - bool is undefined operator!!
  59.  
  60. cout << i1 << endl; // auto cast to bool (1) !! cannot show address!
  61.  
  62.  
  63. bool a = foo(); // OK
  64. int b = foo(); // NG
  65. char c = foo(); // NG
  66.  
  67. bool d = bar(); // OK
  68. int e = bar(); // NG
  69. char f = bar(); // NG
  70.  
  71. bool g = baz(); // OK
  72. int h = baz(); // NG
  73. char i = baz(); // NG
  74.  
  75.  
  76. int j = (int)foo(); // OK
  77. int k = (int)bar(); // NG
  78. int l = (int)baz(); // OK
  79.  
  80. int m = reinterpret_cast<int>(foo()); // OK
  81. int n = reinterpret_cast<int>(bar()); // NG
  82. int o = reinterpret_cast<int>(baz()); // OK
  83.  
  84. void *p = (void*)foo(); // OK
  85. void *q = (void*)bar(); // NG
  86. void *r = (void*)baz(); // OK
  87.  
  88. void *s = reinterpret_cast<void*>(foo()); // OK
  89. void *t = reinterpret_cast<void*>(bar()); // NG
  90. void *u = reinterpret_cast<void*>(baz()); // OK
  91.  
  92. int nat::*v = foo(); // NG
  93. int nat::*w = bar(); // OK
  94. int nat::*x = baz(); // NG
  95. int nat::*y = hoge(); // NG
  96.  
  97. int nat::*_a = (int nat::*)foo(); // NG
  98. int nat::*_b = (int nat::*)bar(); // OK
  99. int nat::*_c = (int nat::*)baz(); // NG
  100. int nat::*_d = (int nat::*)hoge(); // OK
  101.  
  102. int nat::*_e = reinterpret_cast<int nat::*>(foo()); // NG
  103. int nat::*_f = reinterpret_cast<int nat::*>(bar()); // OK
  104. int nat::*_g = reinterpret_cast<int nat::*>(baz()); // NG
  105. int nat::*_h = reinterpret_cast<int nat::*>(hoge()); // OK
  106.  
  107.  
  108. bool _i = hoge(); // OK
  109. int _j = (bool)hoge(); // OK
  110. void *_k = (void*)(bool)hoge(); // OK
  111.  
  112. int nat::*_l = false; // OK
  113. int nat::*_m = (int nat::*)false; // OK
  114. int nat::*_n = (int nat::*)true; // NG
  115.  
  116. int nat::*_o = (bool)foo(); // NG
  117. int nat::*_p = (int nat::*)(bool)foo(); // NG
  118. int nat::*_q = (int nat::*)(bool)0; // OK
  119. int nat::*_r = 0; // OK
  120. int nat::*_s = (bool)0; // OK
  121. int nat::*_t = (int)0; // OK
  122. int nat::*_u = (void*)0; // NG
  123. int nat::*_v = (int*)0; // NG
  124.  
  125. bool __a = false;
  126. int nat::*__b = __a; // NG
  127. int nat::*__c = (int nat::*)__a; // NG
  128. int nat::*__d = reinterpret_cast<int nat::*>(__a); // NG
  129.  
  130. short __e = (short)foo(); // NG
  131. short __f = (short)bar(); // NG
  132. short __g = (short)baz(); // NG
  133.  
  134. short __h = reinterpret_cast<short>(foo()); // NG
  135. short __i = reinterpret_cast<short>(bar()); // NG
  136. short __j = reinterpret_cast<short>(baz()); // NG
  137.  
  138. char __k = reinterpret_cast<char>(foo()); // NG
  139. char __l = reinterpret_cast<char>(bar()); // NG
  140. char __m = reinterpret_cast<char>(baz()); // NG
  141.  
  142. double __n = reinterpret_cast<double>(foo()); // NG
  143. double __o = reinterpret_cast<double>(bar()); // NG
  144. double __p = reinterpret_cast<double>(baz()); // NG
  145.  
  146. long long __r = (long long)foo(); // OK
  147. long long __s = (long long)bar(); // NG
  148. long long __t = (long long)baz(); // OK
  149.  
  150. return 0;
  151. }
  152.  
Compilation error #stdin compilation error #stdout 0s 2728KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:57: error: invalid operands of types 'int Fuga::*' and 'int Fuga::*' to binary 'operator-'
prog.cpp:64: error: invalid conversion from 'void*' to 'int'
prog.cpp:65: error: invalid conversion from 'void*' to 'char'
prog.cpp:68: error: cannot convert 'int nat::*' to 'int' in initialization
prog.cpp:69: error: cannot convert 'int nat::*' to 'char' in initialization
prog.cpp:72: error: invalid conversion from 'int*' to 'int'
prog.cpp:73: error: invalid conversion from 'int*' to 'char'
prog.cpp:77: error: invalid cast from type 'int nat::*' to type 'int'
prog.cpp:81: error: invalid cast from type 'int nat::*' to type 'int'
prog.cpp:85: error: invalid cast from type 'int nat::*' to type 'void*'
prog.cpp:89: error: invalid cast from type 'int nat::*' to type 'void*'
prog.cpp:92: error: cannot convert 'void*' to 'int nat::*' in initialization
prog.cpp:94: error: cannot convert 'int*' to 'int nat::*' in initialization
prog.cpp:95: error: cannot convert 'int hat::*' to 'int nat::*' in initialization
prog.cpp:97: error: invalid cast from type 'void*' to type 'int nat::*'
prog.cpp:99: error: invalid cast from type 'int*' to type 'int nat::*'
prog.cpp:102: error: invalid cast from type 'void*' to type 'int nat::*'
prog.cpp:104: error: invalid cast from type 'int*' to type 'int nat::*'
prog.cpp:114: error: invalid cast from type 'bool' to type 'int nat::*'
prog.cpp:116: error: cannot convert 'bool' to 'int nat::*' in initialization
prog.cpp:117: error: invalid cast from type 'bool' to type 'int nat::*'
prog.cpp:122: error: cannot convert 'void*' to 'int nat::*' in initialization
prog.cpp:123: error: cannot convert 'int*' to 'int nat::*' in initialization
prog.cpp:126: error: cannot convert 'bool' to 'int nat::*' in initialization
prog.cpp:127: error: invalid cast from type 'bool' to type 'int nat::*'
prog.cpp:128: error: invalid cast from type 'bool' to type 'int nat::*'
prog.cpp:130: error: cast from 'void*' to 'short int' loses precision
prog.cpp:131: error: invalid cast from type 'int nat::*' to type 'short int'
prog.cpp:132: error: cast from 'int*' to 'short int' loses precision
prog.cpp:134: error: cast from 'void*' to 'short int' loses precision
prog.cpp:135: error: invalid cast from type 'int nat::*' to type 'short int'
prog.cpp:136: error: cast from 'int*' to 'short int' loses precision
prog.cpp:138: error: cast from 'void*' to 'char' loses precision
prog.cpp:139: error: invalid cast from type 'int nat::*' to type 'char'
prog.cpp:140: error: cast from 'int*' to 'char' loses precision
prog.cpp:142: error: invalid cast from type 'void*' to type 'double'
prog.cpp:143: error: invalid cast from type 'int nat::*' to type 'double'
prog.cpp:144: error: invalid cast from type 'int*' to type 'double'
prog.cpp:147: error: invalid cast from type 'int nat::*' to type 'long long int'
stdout
Standard output is empty