#define
MACRO1(a, b) a(b);
namespace
test_old
{
class C0
{};
struct S0
{};
struct S1
{
C0 c[100];
};
class C1
{
public:
static C1* Construct()
{
static C1 c;
return &c;
};
private:
C1(){};
~C1(){};
};
class C2
{
private:
virtual void m1() = 0;
virtual const char* m3()
{
return "C2-m3";
};
public:
virtual const char* m2()
{
return "C2";
};
virtual const char* m4()
{
return m3();
};
};
class C3 : public C2
{
public:
C3()
{
m1();
};
const char* m2()
{
return "C3";
};
private:
void m1(){};
const char* m3()
{
return "C3-m3";
};
};
template<typename T>
class CT1
{
typedef T DERIVED;
};
template<template<typename> class TT>
class CT2 : public TT<CT2>
{};
typedef CT2<CT1> CTT;
class C4
{
public:
explicit C4(int i)
{
m_i = i;
};
int m_i;
};
C4 f1(C4 c)
{
return c;
};
void fun2()
{};
void fun3(int a, int b)
{};
struct I1
{
virtual void mI1()
{
//void* p = this->__vfptr;
};
};
struct I2
{
virtual void mI2()
{
};
};
class C5 : public I1, I2
{
public:
C5()
{
mI1();
mI2();
};
};
class C6
{
public:
virtual void m1(){};
private:
virtual void m2(){};
};
class C7 : public C6
{
public:
void m2(){};
private:
void m1(){};
};
class C8
{
public:
C8() = 0;
};
class C9 : public C8
{
public:
C8(){};
C9(){};
};
class C10
{
public:
C10() = 0;
};
class C11 : public C10
{
public:
void m1(){};
};
class C12
{
inline virtual m1() = 0;
};
class C13
{
public:
C13():m_d(15){};
double m_d;
};
class C15;
class C14
{
public:
C14(C14* p)
{
bool b = (p == this);
C15* p2 = (C15*)p;
//double d = p2->m_d;
};
const char* m1(){return "C14::m1";};
};
class C15 : public C13, C14
{
public:
C15():C14(this)
{
C15* p1 = this;
C14* p2 = (C14*)this;
bool b = (p1 == p2);
};
};
class C16
{
public:
virtual const char* m1(...){return "C16";};
};
class C17 : public C16
{
const char* m1(int i){return "C17";};
};
class C18
{
public:
virtual C18* m1() = 0;
virtual void m2() = 0;
};
class C19 : public C18
{
public:
virtual C19* m1() = 0;
//virtual int m2() = 0; //error C2555:
“C19::m2”: 重写虚函数返回类型有差异,且不是来自“C18::m2”的 covariant
};
template<typename T>
class CT3
{
//sdfsdf sdfsf;
void m1()
{
sdfsdf dsfs hfghgf !%&*([{<>}])+-*/<<>> ^~;,,,,,,,,,'"'[()]
};
};
//class VECTOR;
typedef class C16 VECTOR;
//#define MACRO2(a, b = 1) a(b)
void Gfun1(){}
void Gfun1(int){}
namespace np1
{
struct S1
{};
}
//using struct np1::S1;
class C20 : public C1//, public C1
{};
#define MACRO2 ;
#define MACRO2 MACRO2
#define MACRO2 ;
#define MACRO3(a) a
#define MACRO3(a) MACRO3(a +a)
template<typename T = int>
class CT4{};
template<int i>
class CT5
{
public:
const char* m1(){return "CT5";};
static const char* m2(){return "CT5";};
const char* m3();
};
//template<>
const char* CT5<1>::m1()
{
return "CT5_1";
};
template<>
const char* CT5<1>::m2()
{
return "CT5_1";
};
template<int i>
const char* CT5<i>::m3()
{
return "CT5_1";
};
template<>
const char* CT5<1>::m3()
{
return "CT5_1";
};
template<template<typename> class T, int i>
class CT6
{
public:
void m1();
void m2(){};
void m3();
};
/*template<template<typename> class T>
class CT6<T, 1>
{
void m1()
{}
};*/
/*template<template<typename> class T, int i>
void CT6<T, 1>::m1()
{}*/
template<template<typename> class T, int i2>
void CT6<T, i2>::m3()
{}
template<typename T, int I>
struct CT7
{
int m1();
int m2();
};
template<typename T, int I>
int CT7<T, I>::m1()
{
return 11;
};
template<typename T>
struct CT7<T, 1>
{
int m1();
int m2();
};
template<typename T>
int CT7<T, 1>::m1()
{
return 21;
};
template<typename T, int I>
int CT7<T, I>::m2()
{
return 12;
};
template <int v>
struct Int2Type
{
enum { value = v };
};
template<typename T, int I>
struct ST8
{
template<int I>
int m1(Int2Type<I> t = Int2Type<I>());
};
/*template<typename T, int I>
int ST8<T, I>::m1(Int2Type<I> t)
{
return 0;
}
template<typename T>
int ST8<T, 1>::m1(Int2Type<1> t)
{
return 1;
}*/
typedef int TD1;
#ifdef TD1
# error
#endif
class C21{};
struct S2 : public C21 {};
template<typename T1, typename T2, typename T3>
class CT9{};
//template<>
//class CT9<none, none, none>{};
struct S3
{
template<typename T>
void m1(){};
};
template<typename T>
class CT10
{
template<typename T2>
T m1(T2);
};
template<typename T>
template<typename T2>
T CT10<T>::m1(T2){}
//template<typename T2>
//T CT10<T>::m1(T2){}
template<typename T, int I>
struct ST11
{
void m1();
};
template<typename T, int I>
void ST11<T, I>::m1(){}
//template<typename T>
//void ST11<T, 1>::m1(){} //error C3860:
类模板名称后面的模板参数列表必须按模板参数列表中使用的顺序列出参数
class C22
{
public:
const char* m1(){return "C22::m1";};
};
typedef const char* (C22::*TpC22_1)();
class C23
{
public:
const char* m1(){return "C23::m1";};
};
const char* fun1(){return "fun1";};
const char* (&g_rfun1)() = fun1;
const char* (*g_pfun1)() = fun1;
template<int I, int I2>
struct ST12
{
static int get_s(){return s_status;};
static void set_s(int s){s_status = s;};
private:
static int s_status;
};
class C24
{
public:
typedef ST12<0, 0> TYPE0;
typedef ST12<1, 1> TYPE1;
typedef ST12<1, 2> TYPE2;
};
int C24::TYPE0::s_status;
int C24::TYPE1::s_status;
int C24::TYPE2::s_status;
template<typename T>
struct ST13
{
ST13(T t){};
};
ST13<int> g_st13(int(0));
struct S4
{
int m_1;
int m_2;
};
typedef int (S4::*TpS4_1);
TpS4_1 g_pS4_1 = &S4::m_1;
struct S5{};
friend struct S4;
struct S6
{
void operator ()(){};
};
void (S6::*g_pS6_op)() = S6::operator ();
struct S7
{
static const int s_ci = 0;
//static int s_vi = 0; // C2864
};
struct S8
{
S8() throw() {};
};
char* g_pi1;
template<typename Num>
Num operator / (Num f1, Num f2)
{
if(!(f2 > 0.0f) && !(f2 < 0.0f))
_asm{int 3};
return f1 / f2;
}
}
namespace
{
template<char i>
struct ST1{};
template<unsigned char i>
struct ST2{};
template<int i>
struct ST3{};
template<unsigned i>
struct ST4{};
template<long i>
struct ST5{};
template<unsigned long i>
struct ST6{};
template<short i>
struct ST7{};
template<unsigned short i>
struct ST8{};
}
namespace
test42
{
class Empty
{
Empty() { ; } // default constructor
Empty(const Empty& rhs) { ; } // copy constructor
~Empty() { ; } // destructor - see below
// for whether it's virtual
Empty& operator=(const Empty& rhs) { ; } // copy assignment operator
};
}
namespace
test43
{
//const int i = 1, i2=2
};
namespace
test44
{
template<template<typename> class T>
void fn(){};
template<typename T> class PT;
}
namespace
test45
{
//template<struct T> //error C2079:
“template-parameter”使用未定义的 struct“T”
struct ST{};
}
namespace
test46
{
template<int I>
struct ST;
//template<int I1, int I2>
// struct ST;
}
namespace
test47
{
struct A
{
template<typename R>
R m1();
};
struct B : A
{
template<typename R>
R m1(){return R();};
};
}
namespace
test48
{
struct A
{
template<typename T>
void m1(T v);
};
typedef void (A::*TpA_1)();
struct A2
{
void m1(int v);
};
}
namespace
test49
{
namespace
{
void anonymous(){};
}
void f()
{
anonymous();
}
}
namespace
test50
{
struct C{};
namespace ns
{
struct A
{
virtual void m1(C&) = 0;
};
}
struct B : ns::A
{
void m1(C&){};
};
}
namespace
test2006_8_7_1
{
class C
{
struct A
{
void m1(){};
};
public:
typedef A A_t;
};
}
namespace
test2006_8_7_2
{
enum NpcType
{
NPCTYPE_BEGIN = 0,
NPCTYPE_DJ = NPCTYPE_BEGIN,
NPCTYPE_LIGHT = 1,
NPCTYPE_LEADER = 2,
NPCTYPE_FIGHTSCOPE = 3,
NPCTYPE_AMBIENT = 4,
NPCTYPE_END,
LIGHT_TYPE_GROUP = 5,
};
}
namespace
test2006_8_17_1
{
class A
{
protected:
A* m1;
};
/*class B : A
{
B()
: m1((B*)(this->A::m1)) //C2440:
“初始化” : 无法从“test2006_8_17_1::B *”转换为“test2006_8_17_1::B *& ”
{};
public:
B*& m1;
};*/
}
namespace
test2006_8_22_1
{
class A
{
//template<int I>
// virtual int m1() = 0; //C2898:
“int test2006_8_22_1::A::m1(void)” : 成员函数模板不能是虚拟的
};
}
namespace
test2006_8_23_1
{
struct A
{
struct A1{};
};
typedef A& T;
//T::A1 a1; //C2825:
“test2006_8_23_1::T::A1”: 不能形成限定名
}
namespace
test2006_8_23_2
{
template<typename T>
struct A
{
static void m1(T);
static void m2(T){};
};
template<>
void A<int>::m1(int){}
A<int> a;
A<bool> a2;
}
namespace
test2006_8_24_1
{
template<typename T>
union UT
{
//UT(){};
};
union U
{
U(){};
UT<U> m1;
};
}
namespace
test2006_8_24_2
{
template<typename>
struct _1;
template<template<typename> class>
struct _2;
template<template<template<typename> class> class>
struct _3;
template<template<template<template<typename> class> class> class>
struct _4;
template<template<template<template<template<template<template<template<template<template<
template<template<template<template<template<template<template<template<template<template<
template<template<template<template<template<template<template<template<template<template<
template<template<template<template<template<template<template<template<template<template<
template<template<template<template<template<template<template<template<template<template<
template<template<template<template<template<template<template<template<template<template<
template<template<template<template<
typename
> class> class> class> class> class> class> class> class> class>
class> class> class> class> class> class> class> class> class> class>
class> class> class> class> class> class> class> class> class> class>
class> class> class> class> class> class> class> class> class> class>
class> class> class> class> class> class> class> class> class> class>
class> class> class> class> class> class> class> class> class> class>
class> class> class> class>
struct _64;
typedef _2<_1> T21;
typedef _3<_2> T32;
typedef _4<_3> T43;
}
namespace
test2006_8_24_3
{
struct A
{
static const int i = 0;
virtual void m1() = 0;
//virtual void m2() = m1;
};
}
namespace
test2006_8_24_4
{
//extern "B" fn();
//"C" fn2();
template <typename T>
static void internal();
}
namespace
test2006_8_24_4
{
template<typename T, T* p>
struct A;
}
namespace
test2006_8_25_1
{
template<int I1, int I2>
struct A;
template<int I2>
struct A<1, I2>
{
enum {value = 0};
};
template<int I1>
struct A<I1, 1>
{
enum {value = 1};
};
typedef A<1, 1> A_1_1;
//int v = A_1_1::value; //C2752:
“test2006_8_25_1::A<I1,I2>” : 多个部分专用化与模板参数列表匹配
}
namespace
test2006_8_29_1
{
//void fun(int){}
void fun(int = 1){}
void fun2(int , int = 1);
void fun2(int = 1, int);
}
namespace
test2006_8_29_2
{
template<typename T> void fun();
//template<template<typename> void (*)()>
// struct A;
}
namespace
test2006_8_29_3
{
template<const char* name>
struct Container
{
const char* getName(){return name;};
};
extern const char abc[] = "abc";
typedef Container<abc> Abc;
}
namespace
test2006_8_29_4
{
extern int i;
//int i2 = i;
}
namespace
test2006_8_29_5
{
template<int I>
struct A;
static const int i = 0;
typedef A<i> Ai;
}
namespace
test2006_8_29_6
{
struct A
{
friend void fun(){};
};
}
namespace
test2006_8_30_1
{
struct A
{
virtual int m1(){return 1;};
};
struct B : A
{
int m1(){return 2;};
};
struct C : B
{
int m1(){return 3;};
};
}
namespace
test2006_8_30_2
{
class A;
class A;
}
namespace
test2006_8_30_3
{
template<typename T>
void f(T, T){}
void (*pf)(char, char) = &f;
void (*pf2)(int, int) = &f;
}
namespace
test2006_8_30_4
{
//template<double d> // C2993:
“double” : 非类型模板参数“d”的类型非法
struct A;
}
namespace
test2006_8_30_5
{
//int i[2] = {[0] = 1, [1] = 2};
}
namespace
test2006_8_31_1
{
//auto a; // C2390:
“a” : 不正确的存储类“auto”
//register r; // C2390:
“r” : 不正确的存储类“register”
static s;
volatile v;
void fun()
{
auto a;
register r;
static s;
volatile v;
extern e;
//extern static es; // C2159:
指定了一个以上的存储类
}
}
namespace
test2006_8_31_2
{
template<int i, typename T>
void f(T v){};
}
namespace
test2006_8_31_3
{
template<int I>
struct A
{
typedef typename A<I + 1>::T T;
};
template<>
struct A<948> // 948 is the upper limit
{
typedef int T;
};
A<0>::T t;
template<int I>
struct B
{
void m1(){B<I - 1>().m1();};
};
template<>
struct B<0>
{
void m1(){};
};
}
namespace
test2006_9_4_1
{
typedef int INT;
typedef int INT;
}
namespace
test2006_9_6_1
{
struct A
{
operator int (){return 1;};
};
struct B
{
operator A (){return A();};
};
void fun(double){}
}
namespace
test2006_9_6_2
{
template<typename T>
struct A
{
typedef A<A<T> > Nest;
typedef typename Nest::Recursion Recursion;
typedef typename A<T>::Self Self;
};
//A<void> a;
}
namespace
test2006_9_6_3
{
struct A
{
static const int i0 = 1;
static const unsigned int i1 = 1;
static const bool i2 = 1;
static const long i3 = 1;
static const long long i4 = 1;
};
}
namespace
test2006_9_7_1
{
//private: struct A;
}
#define
MACRO4 #define MACRO4_G
//MACRO4 // C2121:
“#” : 无效字符 : 可能是宏展开的结果
#ifdef
MACRO4_G
#error
#endif
namespace
test2006_9_14_1
{
struct A
{
A(int i):i_(i){};
int& i_;
};
}
namespace
test2006_9_21_1
{
struct A
{
template<typename T>
T m1(){return T();};
template<int I>
void m2(){};
};
}
namespace
test2006_9_27_1
{
template<typename S1, typename S2>
struct A
{
void m1(typename S1::P);
void m1(typename S2::P);
};
struct Sp1
{
typedef int P;
};
struct Sp2
{
typedef float P;
};
struct Sp3
{
typedef int P;
};
typedef A<Sp1, Sp2> Ap1;
typedef A<Sp1, Sp3> Ap2;
//Ap2 a;
}
namespace
test2006_10_11_1
{
struct A
{
//friend struct B{}; C2391:
“test2006_10_11_1::A::B” : “friend”不能在类型定义过程中使用
};
}
namespace
test2006_11_1_1
{
struct A
{
A()
{
int i;
}
};
}
namespace
test2006_11_9_1
{
enum{};
struct{};
static union{};
class{};
}
namespace
test2006_11_10_1
{
struct _123456789{};
template<typename H, typename T>
struct L123456789{};
template<typename T>
struct C
{
C(){};
};
}
namespace
test2006_11_17_1
{
struct A;
struct B
{
A output();
};
template<typename> struct T;
typedef T<A> TA;
}
namespace
test2006_11_20_1
{
struct A
{
virtual void operator = (const A&) = 0;
};
}
namespace
test2006_11_22_1
{
struct _
{
//void operator [] ();
void operator [] (int);
//_ operator [] (int, int);
void operator [] (char);
void operator () ();
void operator () (int);
void operator () (int, int);
void operator () (int, int, int);
//void operator <> ();
//void operator <> (int);
//void operator <> (int, int);
};
}
namespace
test2006_11_23_1
{
int test()
{
static int i = 0;
++ i;
return i;
}
}
namespace
test2006_11_23_2
{
int fn()
{
return 0;
}
int p();
}
namespace
test2006_11_23_3
{
struct A;
struct A
{
struct A;
//struct B : A{}; // C2504:
“test2006_11_23_3::A” : 未定义基类
};
}
namespace
test2006_11_23_4
{
void fn()
{
struct A
{
A()
{
fn();
}
};
A a;
}
struct B
{
B()
{
B b;
}
};
//fn::A::A()
/*A::A()
{}*/
}
namespace
test2006_11_24_1
{
struct A
{
//void operator . (); // C2800:
无法重载“operator .”
void operator -> ();
void operator ->* (A&);
};
}
namespace
test2006_11_29_1
{
struct A{};
namespace op
{
int operator + (A&, A&){return 0;};
}
}
namespace
test2006_12_1_1
{
void fn(int a[3])
{
size_t s = sizeof(a); // s -> 4
}
}
namespace
test2006_12_5_1
{
template<typename T>
struct A : T{};
typedef A<int> A_I;
//A_I a_i;
class B;
typedef A<B> A_B;
//class B : public A<B>{};
}
namespace
test2006_12_5_2
{
//class INT;
typedef int INT;
typedef int INT;
typedef signed int INT;
struct A;
class A;
//union A;
}
namespace
test2006_12_7_1
{
const void fn1();
//void& fn2(); // C2182:
“fn2” : 非法使用“void”类型
//void fn3(const void v);
}
namespace
test2007_1_15_1
{
struct A{};
struct B{};
struct Convert
{
template<typename T>
Convert(const T&);
template<typename T>
operator T();
};
int fun(A);
}
namespace
test2007_1_26_1
{
template<typename T>
struct TT
{
friend struct TT;
TT()
{
TT<int> t;
t.foo();
};
private:
void foo(){};
};
}
namespace
test2007_1_31_1
{
template<typename T>
struct TT;
typedef TT<void(int)>;
}
namespace
test2007_3_5_1
{
void f();
void f2(void (*pf)() = f);
}
namespace
test2007_3_5_2
{
long f();
typedef long (F)();
typedef long (*PF)();
typedef long (&RF)();
template<F pf> struct TT;
typedef TT<f> TF;
typedef TT<0> TN;
template<PF pf> struct PTT;
typedef PTT<f> PTF;
template<RF pf> struct RTT;
typedef RTT<f> RTF;
struct P{};
//template<P p> struct TT2; // C2993:
“test2007_3_5_2::P” : 非类型模板参数“p”的类型非法
}
namespace
test2007_3_5_3
{
typedef void (*PF)();
typedef void (RF)();
//RF r; // LNK2001:
无法解析的外部符号 "void __cdecl test2007_3_5_3::r(void)" (?r@test2007_3_5_3@@YAXXZ)
//PF p = r;
//RF r2 = p; // C2072:
“test2007_3_5_3::r2” : 函数的初始化
}
namespace
test2007_3_5_4
{
#define
private public
class C
{
private:
int m;
};
void f()
{
C c;
c.m = 1;
}
#undef
private
}
namespace
test2007_3_5_5
{
template<template<typename> class TTP> struct TT;
template<typename T> struct TC;
typedef TT<TC> TTI;
}
namespace
test2007_3_5_6
{
template<int I> struct ST
{
const int* get()
{
//return &I; // C2101:
常数上的“&”
};
};
}
namespace
test2007_3_5_7
{
template<int>
struct Outer
{
template<int>
struct Inner
{
static int i;
};
//Inner<1>::i; // C3210:
“Inner<1>” : 访问声明只能应用于基类成员
};
//int g_i = Outer<1>::Inner<1>::i; // LNK2001:
无法解析的外部符号 "public: static int test2007_3_5_7::Outer<1>::Inner<1>::i" (?i@?$Inner@$00@?$Outer@$00@test2007_3_5_7@@2HA)
}
namespace
test2007_3_6_1
{
struct S
{
void f()
{
int i = 0;
}
void f() const
{
int i = 0;
}
};
}
namespace
test2007_3_7_1
{
template<int, int> struct ST;
template<int I, int I2> void f(ST<I, I2>);
struct B
{
protected:
//void f();
void abcf();
};
namespace abc
{
void abcf();
}
template<int I1, int I2 = 0> struct ST : public B
{
friend void f<>(ST);
friend void abc::abcf();
friend void abcf();
private:
void privatef(){};
//void f();
};
namespace abc
{
void abcf()
{
ST<1, 1> s;
s.privatef();
}
}
template<int I, int I2> void f(ST<I, I2> sti)
{
sti.privatef();
}
typedef ST<1> ST_1_0;
ST_1_0 s;
}
namespace
test2007_3_8_1
{
typedef int INT4[4];
//INT4 getArray(); // C2090:
函数返回数组
}
namespace
test2007_3_8_2
{
struct INT4
{
int a[4];
};
INT4 sort(const INT4 a)
{
INT4 src = a, dst = {{0, 1, 2, 3}};
for(int i = 0; i < 3; ++ i)
for(int j = 0; j < 3 - i; ++ j)
if(src.a[j] > src.a[j + 1])
{
int tmp = src.a[j];
src.a[j] = src.a[j + 1];
src.a[j + 1] = tmp;
tmp = dst.a[j];
dst.a[j] = dst.a[j + 1];
dst.a[j + 1] = tmp;
}
return dst;
}
}
namespace
test2007_3_8_3
{
extern "C"
{
struct S
{
S();
void S::f();
void f(int){};
};
}
}
namespace
test2007_3_10_1
{
struct S
{
union
{
int x1, x2;
};
union
{
int y1, y2;
};
} s;
void f()
{
s.x1 = 0;
}
}
namespace
test2007_3_14_1
{
struct A
{
void c();
};
struct B
{
friend void
A::c();
};
}
namespace
test2007_3_15_1
{
struct A
{
void mf(){};
};
struct B
{
void mf(){};
};
typedef void (A::*AMF_t)();
typedef void (B::*BMF_t)();
void f(void* p, BMF_t fun)
{
A* a;
AMF_t amf;
(a->*amf)();
BMF_t bmf = reinterpret_cast<BMF_t>(amf);
//void* funv = fun;
//void (A::*funamf)() = reinterpret_cast<AMF_t>(funv);
(reinterpret_cast<A*>(p)->*reinterpret_cast<AMF_t>(fun))();
}
}
namespace
test2007_4_3_1
{
struct S
{
int operator , (int i)
{
return i;
};
};
S s;
}
namespace
test2007_4_13_1
{
template<typename T>
struct T_HaveF
{
typedef char yes_t;
struct no_t
{
char stuff[2];
};
template<typename T2>
static yes_t test(int (T2::*F)(void) = T2::f);
template<typename T2>
static no_t test(...);
enum {result = sizeof(test<T>())};
};
struct A
{
int f();
int f(int);
};
}
namespace
test2007_4_18_1
{
struct B
{
~B()
{
int i = 0;
}
};
struct S
{
S()
{
throw 0;
}
~S()
{
int i = 0;
}
B b;
};
}
namespace
test2007_4_21_1
{
struct Out
{
struct In
{
In()
{
int ii = Out::i;
Out::foo();
}
};
private:
static const int i = 1;
static void foo(){};
};
}
namespace
test2007_4_25_1
{
template<int I>
struct S
{
struct D;
template<int II> struct TD;
//typedef typename D::T ST; // C2039:
“T” : 不是“test2007_4_25_1::S<I>::D”的成员
//typedef typename TD<I>::T ST; // C2027:
使用了未定义类型“test2007_4_25_1::S<I>::TD<II>”
};
template<> struct S<1>::D
{
typedef int T[1];
};
template<> template<> struct S<1>::template TD<1>
{
typedef int T[1];
};
S<1>::D d;
}
namespace
test2007_4_25_2
{
struct B
{
friend struct D;
private:
int i;
};
struct D : public B
{
D()
{
int ii = i;
}
};
}
namespace
test2007_4_25_3
{
class B
{
protected:
static int b;
};
class D : public B
{
friend class F;
D()
{
int i = B::b;
}
};
class F
{
F()
{
int i = B::b;
}
};
}
namespace
test2007_4_26_1
{
struct R
{
R(int& a_)
: a(a_)
{
};
int& a;
};
int i(0);
R g_r(i);
struct O
{
O(R& r)
: a(r.a)
{
};
int a;
};
O g_o(g_r);
}
namespace
test2007_4_26_2
{
struct O
{
int a;
};
O g_o;
struct R
{
R(O& o)
: a(o.a)
{
};
int& a;
};
R g_r(g_o);
}
namespace
test2007_4_27_1
{
bool foo()
{
int i = 0;
return false;
}
}
namespace
test2007_4_30_1
{
template<typename T, T t> struct ST;
template<typename T, T t> void fn();
template<typename T, T t, template<int> class TP> struct ST2;
template<typename T, template<T> class TP, T t> struct ST3;
template<typename T, template<T> class TP, T t> void fn2();
}
namespace
test2007_4_30_2
{
const void f();
}
namespace
test2007_4_30_3
{
template<typename T, typename T2, template<T> class TP>
struct Outer
{
template<T I>
struct Inner
{};
};
}
namespace
test2007_4_30_4
{
//int&& i; //C2143:
语法错误 : 缺少“;”(在“&&”的前面)
typedef int& IntRef;
//typedef IntRef& IntRefRef; // C2529:
“IntRefRef” : 引用的引用非法
//const const int ci; // C2734:
“test2007_4_30_4::ci” : 如果不是外部的,则必须初始化常数对象
typedef const int ConstInt;
typedef const ConstInt ConstConstInt;
}
namespace
test2007_4_30_5
{
class C
{
public:
char operator + (const char*);
};
C g_c;
//C operator + (C x, C y);
//template<typename T>
// long operator + (C x, T y);
struct S
{
static C operator + (C x, C y);
template<typename T>
static long long operator + (C x, T y);
enum
{
s = sizeof(S::operator + (g_c, g_c)),
s2 = sizeof(operator + (g_c, g_c)),
//s3 = sizeof(g_c + g_c), // C2676:
二进制“+” : “test2007_4_30_5::C”不定义该运算符或到预定义运算符可接收的类型的转换
s4 = sizeof(operator + (g_c, 1)),
s5 = sizeof(operator + (g_c, "")),
};
};
enum
{
//s = sizeof(operator + (g_c, 1)),
s2 = sizeof(g_c + ""),
};
}
namespace
test2007_5_10_1
{
template<typename T, int N>
void f(T a[N])
{
}
template<typename T>
void f2(T a[])
{
}
}
namespace
test2007_5_15_1
{
struct Common
{
typedef void (*F_v_i)(int);
template<typename T>
F_v_i operator ->* (void (T::*p)(int))
{
return reinterpret_cast<T*>(this)->*p;
}; // C4716:
“test2007_5_15_1::Common::operator->*<test2007_5_15_1::S>” : 必须返回一个值
};
template<typename T>
void gf(T p)
{
}
struct S
{
void f(int i)
{
int ii = 0;
};
};
}
namespace
test2007_5_18_1
{
template<int I1, int I2, int I3, int I4, int I5> struct T
{
static int i(){return 0;};
};
}
void
main()
{
{
using namespace test_old;
C1* c = C1::Construct();
C3 c3;
C2* pc = &c3;
const char* string1 = pc->m2();
const char* string2 = c3.m2();
const char* string3 = pc->m4();
char str0[] = "Hello";
char *pstr0 = str0;
char str1[100];
size_t s0 = sizeof(C0);
size_t s1 = sizeof(C1);
size_t s2 = sizeof(C2);
size_t s3 = sizeof(C3);
size_t s4 = sizeof(S0);
size_t s5 = sizeof(str0);
size_t s51 = sizeof(pstr0);
size_t s52 = sizeof(str1);
size_t sz6 = sizeof(size_t);
CTT ctt;
C4 c4(1);
c4 = f1((C4)2);
S0 _1, _2;
_2 = _1;
C5 c5;
size_t s6 = sizeof(I1);
size_t s7 = sizeof(I2);
C7 c7;
c7.m2();
//c7.m1();
C6* pc6 = &c7;
pc6->m1();
//pc6->m2();
//C9 c9;
C15 c15;
C14* pc14 = (C14*)&c15;
const char* str = pc14->m1();
C17 c17;
C16* pc16 = &c17;
const char* str2 = pc16->m1(1);
MACRO1(fun2);
//MACRO1(fun3, 1, 2);
//void* pv = Gfun1;
void (*pv2)(int);
pv2 = Gfun1;
/*module( pv2, "dsfs" )
[
//def("createTimer", &yake::base::timer::createTimer())
class_< C6 >( "C6" )
.def( "m1", &C6::m1 )
];*/
MACRO2;
//int i1 = MACRO3(1);
CT4<> ct4;
CT5<0> ct5_0;
CT5<1> ct5_1;
const char* str3 = ct5_0.m1();
const char* str4 = ct5_1.m1();
const char* str5 = CT5<0>::m2();
const char* str6 = CT5<1>::m2();
CT6<CT4, 0> ct6;
ct6.m2();
/*CT7<int, 1> ct7;
int i1 = ct7.m1();
int i2 = ct7.m2();*/
S2 s_2;
S3 s_3;
s_3.m1<int>();
auto v0;
TpC22_1 pC22_1_1 = &C22::m1;
C22 c22;
const char* str7 = (c22.*pC22_1_1)();
typedef const char* (C23::*TpC23_1)();
pC22_1_1 = (TpC22_1)(C23::m1);
C23 c23;
const char* str10 = (c23.*(TpC23_1)pC22_1_1)();
const char* str11 = (c23.*C23::m1)();
//const char* str12 = (c23.*C22::m1)();
const char* str8 = g_rfun1();
const char* str9 = g_pfun1();
C24::TYPE0::set_s(0);
C24::TYPE1::set_s(1);
C24::TYPE2::set_s(2);
int i0 = C24::TYPE0::get_s();
int i1 = C24::TYPE1::get_s();
int i2 = C24::TYPE2::get_s();
S4 s_4;
s_4.m_1 = 41;
s_4.m_2 = 42;
int i3 = s_4.*g_pS4_1;
TpS4_1 pS4_2 = &S4::m_2;
int i4 = s_4.*pS4_2;
int i5 = 2, i6 = 3;
int i7 = i5 +++ i6; // i5 -> 3, i6 -> 3, i7 -> 5
/*S0* ps0 = new S0;
delete ps0;
new(2, (ps0)) S0;
ps0->~S0();*/
//char* pi1 = new (sizeof(int)) int;
//new (int(*g_pi1)) int;
volatile int i8;
float f0 = 0.0f;
float f1 = 1.0f / f0;
do
{}while(false);
char ch1 = 0;
ch1 ++;
(char)300;
bool b1 = ch1 < 300;
test44::fn<test44::PT>();
const type_info& ti1 = typeid(int);
const type_info& ti2 = typeid(unsigned int);
const type_info& ti3 = typeid(short);
const type_info& ti4 = typeid(long);
const type_info& ti5 = typeid(float);
const type_info& ti6 = typeid(double);
const type_info& ti7 = typeid(C2);
const type_info& ti8 = typeid(void);
const type_info& ti9 = typeid(void*);
const type_info& ti10 = typeid(C3);
const type_info& ti11 = typeid(C3*);
}
{
/*using namespace test48;
A a;
a.m1(0);
//TpA_1 p = &A::m1<int>;
//(a.*p)(0);
test48::A2 a2;
(a2.*(&test48::A2::m1))(0);*/
}
{
test49::f();
test49::anonymous();
}
{
using namespace test50;
ns::A* a = new B;
a->m1(C());
}
{
using namespace test2006_8_7_1;
C::A_t a;
//C::A a2; // C2248:
“test2006_8_7_1::C::A” : 无法访问 private struct(在“test2006_8_7_1::C”类中声明)
a.m1();
}
{
int i = _MSC_VER; // 1310
int i2 = 0;
}
{
const int _1 = 1;
const int _2 = 2;
const int _3 = 3;
int _4 = 4;
struct A
{
const int i;
//static const int i2 = 5; //C2246:
“main::A::i2” : 本地定义的类中的非法静态数据成员
A():i(0){};
};
A a;
int i;
switch(i)
{
case _1:
case _2:
case _3:
//case a.i:
//case A::i2:
//case ((const int)_4):
;
}
}
{
struct A;
struct B;
struct A
{
A()
{
new B;
};
};
struct B
{
B()
{
new A;
};
};
//A a;
struct C
{
C(){new C;};
};
//C c;
}
{
using namespace test2006_8_29_3;
Abc a;
const char* name = a.getName();
name = abc;
int i = 0;
}
{
using namespace test2006_8_30_1;
A* p = new C;
int i = p->m1(); // i -> 3
delete (C*)p;
}
{
/*int i;
switch(i)
{
case 0 ... 9:
{
break;
}
default:break;
}*/
}
{
using namespace test2006_8_31_2;
f<0>(1);
}
{
using namespace test2006_8_31_3;
B<100>().m1();
}
{
size_t i = sizeof(long long);
//size_t i2 = sizeof(long long long);
i = 0;
//size_t i3 = sizeof(void);
}
{
struct A
{
A():m(1){};
~A(){};
int m;
};
A a;
//a.A(); // C2274:
“函数样式转换” : 位于“.”运算符右边时非法
a.~A();
int i = a.m; // i -> 1
}
{
struct A;
struct B;
struct C;
struct D;
struct A
{
operator B&(){return B();};
};
struct B
{
operator C&(){return C();};
};
struct C
{
operator D&(){return D();};
};
struct D
{
};
A a;
B b = a;
//C c = a; // C2440:
“初始化” : 无法从“main::A”转换为“main::C”
//D d = a;
}
{
struct A;
struct B;
struct C;
struct D;
struct A{};
struct B
{
B(A&){};
operator C&(){return C();};
};
struct C
{
C(){};
C(B&){};
};
struct D
{
D(C&){};
};
A a;
B b = a;
//C c = a; // C2440:
“初始化” : 无法从“main::A”转换为“main::C”
//D d = a;
}
{
using namespace test2006_9_6_1;
fun(A());
//fun(B()); // C2664:
“test2006_9_6_1::fun” : 不能将参数 1 从“test2006_9_6_1::B”转换为“double”
}
{
using namespace test2006_9_14_1;
int i = 3;
A a(i);
A a2 = a;
int i2 = a2.i_;
i = 0;
}
{
using namespace test2006_9_21_1;
A a;
a.m1<int>();
typedef int (A::*T)();
T p = A::m1<int>;
typedef void (A::*T2)();
T2 p2 = A::m2<0>;
(a.*p)();
}
{
//#001 void main()
//#002 {
//#003 for (int ival=0; ival< 10; ++ival);
//#004 for (int ival=0; ival< 10; ++ival);
//#005 }
}
{
bool b = 010 == 8;
bool b2 = b;
}
{
#define
MACRO5 1
#define
MACRO5 2
int i = MACRO5;
i = MACRO5;
}
{
goto l;
l:;
}
{
class B
{
protected:
void p1(){};
public:
static void p2(){};
};
class D : /*default*/ B
{
D()
{
p1();
p2();
};
};
B::p2();
//D::p2(); // C2248:
“main::B::p2” : 无法访问 private 成员(在“main::D”类中声明)
}
{
signed si = 0x80000000;
signed si2 = 0x80000001;
signed si3 = 0x7fffffff;
unsigned ui = 0x80000000;
unsigned ui2 = 0x80000001;
unsigned ui3 = 0x7fffffff;
bool b4 = si < ui; // true
bool b5 = si == ui; // true
bool b10 = si == signed(ui); // true
bool b6 = si2 > si; // true
bool b7 = ui2 > ui; // true
bool b8 = si3 > si; // true
bool b9 = ui3 < ui; // true
bool b11 = si3 < si2; // false
bool b12 = ui3 < ui2; // true
bool b13 = si3 < ui2; // true
bool b16 = si2 < ui3; // false
bool b14 = si3 < signed(ui2); // false
bool b15 = unsigned(si3) < ui2; // true
bool b = signed(0x80000000) == -1; // false
bool b2 = signed(0x80000000) < unsigned(0x80000000); // false
bool b3 = 0; // false
}
{
char* p = "abc";
//p[0] = 'f'; // CppSyntax.exe
中的 0x0040af1e 处未处理的异常: 0xC0000005: 写入位置 0x0044820c 时发生访问冲突 。
}
{
try
{
try
{
throw 0;
}
catch(...)
{
throw 0;
}
}
catch(...)
{
int i;
//throw 0;
}
}
{
using namespace test2006_11_1_1;
delete new A;
delete new A();
}
{
int i;
int i2 = i;
int i3 = i;
}
{
L"abcd";
//S"abcd"; // C1190
}
{
typedef int;
}
{
using namespace test2006_11_10_1;
#define
ENUMERATE10(f) /
f(_123456789) f(_123456789) f(_123456789) f(_123456789) f(_123456789) f(_123456789) f(_123456789) f(_123456789) f(_123456789) f(_123456789)
#define
ENUMERATE100(f) /
ENUMERATE10(f) ENUMERATE10(f) ENUMERATE10(f) ENUMERATE10(f) ENUMERATE10(f) ENUMERATE10(f) ENUMERATE10(f) ENUMERATE10(f) ENUMERATE10(f) ENUMERATE10(f)
#define
ENUMERATE1000(f) /
ENUMERATE100(f) ENUMERATE100(f) ENUMERATE100(f) ENUMERATE100(f) ENUMERATE100(f) ENUMERATE100(f) ENUMERATE100(f) ENUMERATE100(f) ENUMERATE100(f) ENUMERATE100(f)
#define
ENUMERATE10000(f) /
ENUMERATE1000(f) ENUMERATE1000(f) ENUMERATE1000(f) ENUMERATE1000(f) ENUMERATE1000(f) ENUMERATE1000(f) ENUMERATE1000(f) ENUMERATE1000(f) ENUMERATE1000(f) ENUMERATE1000(f)
#define
ENUMERATE(f) /
ENUMERATE100(f)
#define
Begin(type) L123456789<type,
#define
End(type) >
typedef
ENUMERATE(Begin)
_123456789
ENUMERATE(End)
TT;
C<TT> c;
#undef
Begin
#undef
End
#undef
ENUMERATE
#undef
ENUMERATE1000
#undef
ENUMERATE100
#undef
ENUMERATE10
}
{
int i0 = 1, i1 = 2;
int i = (i0, i1, 3, 4, 5); // i -> 5
int i2 = i;
(i, i2) = (1, 2); // i -> 5, i2 -> 2
int i3 = i;
}
{
//#define MA MB
//#define MB MA
//MA
}
{
int i = 1;
i <<= 2;
}
{
float f = 1.3292279957849158729038070602803e+36;
double d = 1.1235582092889474423308157442431e+307;
long double ld = 1.1235582092889474423308157442431e+307;
int i = 1020;
size_t s = sizeof(long double);
/*while(true)
{
f *= 2;
d *= 2;
ld *= 2;
++ i;
}*/
}
{
int i = 0 ^ 1; // i -> 1
int i2 = 0;
bool b = true ^ true;
}
{
char i = 4;
i >>= 1;
int i2 = i;
}
{
typedef int INT;
//typedef unsigned INT UINT;
//typedef long INT LONG;
typedef const INT CINT;
}
{
unsigned char uc = 0xfc;
uc = -uc;
int i = 0;
}
{
int array[10];
int s1 = sizeof(array);
int i = 0;
}
{
int i = 0x7f;
int i2 = ~ i;
//int i3 = i ~; // error
struct A{};
A a;
size_t s = sizeof A;
size_t s2 = sizeof a;
i = 0;
//malloc(5); // C3861:
“malloc”: 即使使用参数相关的查找,也未找到标识符
}
{
using namespace test2006_11_23_1;
for(int i = 0; test(); ++ i)
{
if(i > 10)
break;
}
}
{
using namespace test2006_11_23_2;
int fn();
int p2();
int (*p3)();// = fn;
int (&p4)() = fn;
//p3();
//p2 = fn;
//p = fn;
}
{
//size_t s = sizeof(__m128); // C2065:
“__m128” : 未声明的标识符
int i = 0;
}
{
//test2006_11_23_4::fn();
}
{
int* p = new int[0];
//p = new int[-1];
int i = 0;
}
{
#define
String(x) #x
const char* s1 = String(abcd);
const char* s2 = String(("abcd"));
#undef
String
}
{
using namespace test2006_11_29_1;
A a1, a2;
//int i = a1 + a2; // C2676:
二进制“+” : “test2006_11_29_1::A”不定义该运算符或到预定义运算符可接收的类型的转换
int i = op::operator + (a1, a2);
}
{
using namespace test2006_12_1_1;
int a[] = {1};
fn(a);
//fn({1}); // C2143:
语法错误 : 缺少“)”(在“{”的前面)
}
#define
a b
#define
b a
//a // C2065:
“a” : 未声明的标识符
#undef
a
#undef
b
{
//using namespace abc;
}
{
//size_t s = sizeof(void); // C2070:
“void”: 非法的 sizeof 操作数
}
{
using namespace test2007_1_15_1;
//sizeof(fun(B())); // C2664:
“test2007_1_15_1::fun” : 不能将参数 1 从“test2007_1_15_1::B”转换为“test2007_1_15_1::A”
sizeof(fun(Convert(B())));
}
{
using namespace test2007_1_26_1;
//TT<float> t;
}
{
struct C
{
C(){};
C(const C& c)
{
int i = 0;
};
C& operator = (const C& c)
{
return *this;
};
};
C c1;
C c2 = c1;
}
{
struct S
{
int* p;
S() : p(new int)
{}
~S()
{
delete p;
}
};
try
{
S s;
throw 0;
}
catch(...)
{
}
}
{
using namespace test2007_3_5_6;
ST<1> t;
//const int* p = t.get();
int i = 0;
}
{
//int i = reinterpret_cast<int>(1.0f); // C2440:
“reinterpret_cast” : 无法从“float”转换为“int”
//float f = reinterpret_cast<float>(1); // C2440:
“reinterpret_cast” : 无法从“int”转换为“float”
}
{
struct Int
{
operator int()
{
return 0;
};
};
Int ii;
int i = Int(ii);
}
/*{
float i = -1e+200 * 1e+200;
bool b1 = i < 0.0;
bool b2 = i == 0.0;
bool b3 = i > 0.0;
i = 0;
}*/
{
using namespace test2007_3_6_1;
S s;
const S cs;
s.f();
cs.f();
}
{
class B
{
protected:
void b(){};
};
class D : public B
{
friend class C;
};
class C
{
C()
{
D d;
d.b();
}
};
}
{
using namespace test2007_3_7_1;
f(s);
}
{
int i = L'1';
i = 0;
}
{
struct A
{
void mf()
{
int i = 0;
};
};
struct B
{
//void mf();
};
typedef void (A::*AMF_t)();
typedef void (B::*BMF_t)();
A a;
(reinterpret_cast<B*>(&a)->*reinterpret_cast<BMF_t>(A::mf))();
}
{
using namespace test2007_4_3_1;
int i = (s, 123);
// i -> 0
int i0 = 0;
}
{
using namespace test2007_4_13_1;
size_t i = T_HaveF<A>::result;
bool b = i == 1;
}
{
using namespace test2007_4_18_1;
try
{
S s;
}
catch(...)
{}
}
{
class A
{
public:
int _1, _2;
};
A a = {1, 2};
}
{
enum E{_=0, _2 = 0x0fffffffffffffff};
size_t s = sizeof(E);
int i = 0;
}
{
typedef int T;
T a;
{
typedef bool T;
T a;
}
{
typedef void* T;
T a;
}
}
{
typedef void (T1)(int/* = 0*/); // C2383:
“T1” : 此符号中不允许有默认参数
}
{
#define
String(text) #text
const char* s = String(abc);
#define
Trigger(f) f(xxxxxxxxxxxxxxx), f(yyyyyyyyyyyyyyy), f(zzzzzzzzzzzz)
const char* s2[] = {Trigger(String)};
int i = 0;
#undef
String
}
{
using namespace test2007_4_27_1;
bool b = true || foo();
bool b2 = false || foo(); // call foo
bool b3 = false && foo();
bool b4 = true && foo(); // call foo
}
{
bool b1 = 1;
bool b2 = 2;
bool b = (b1 == b2);
int i = 0;
}
{
using namespace test2007_4_30_5;
int i1 = S::s4; // 8
//int i2 = s; // 4
int i3 = s2; // 1
int i4 = S::s5; // 8
int i = 0;
}
{
int a[10];
int a1[10][10];
int a2[10][10][10];
int a3[10][10][10][10];
size_t s = sizeof(a); // 40
size_t s1 = sizeof(a1); // 400
size_t s2 = sizeof(a2); // 4000
size_t s3 = sizeof(a3); // 40000
int i = 0;
}
{
struct A
{
int v1;
int v2;
};
struct B
{
B(A& a) : v1(a.v1) {};
int v1;
};
A a = {1, 2};
B b = a;
//B& rb = a; C2440:
“初始化” : 无法从“main::A”转换为“main::B &”
}
{
struct B
{
int v1;
};
struct A : public B
{
int v2;
};
//A a = {{1}, 2}; // error C2552:
“a” : 不能用初始值设定项列表初始化非聚合
A a;
a.v1 = 1;
a.v2 = 2;
B& b = a;
B bi;
bi.v1 = 3;
b = bi;
int i = 0;
}
{
using namespace test2007_5_10_1;
int a[5];
int* p;
//f(a); // C2784:
“void test2007_5_10_1::f(T [N])” : 未能推导出“T1 [N]”(从“int [5]”中)的模板参数
//f(p); // C2784:
“void test2007_5_10_1::f(T [N])” : 未能推导出“T1 [N]”(从“int *”中)的模板参数
f<int, 5>(a);
f2(a);
f2(p);
}
{
int i;
float f;
bool b1, b2, b3, b4;
bool ba[100];
int* p;
int* pi = new int;
float* pf = new float;
bool *pb1 = new bool, *pb2 = new bool, *pb3 = new bool, *pb4 = new bool;
bool* pba = new bool[100];
int** pp = new int*;
i = 0;
}
#if
defined(RTTI) | defined(_RTTI) | defined(_RTTI_) | defined(__RTTI) | defined(__RTTI__)
# error
#endif
{
struct{int a,b;} s1;
//struct{int a,b;} s2 = s1; // C2440:
“初始化” : 无法从“”转换为“”
}
{
int export;
}
{
unsigned long s = 0x60000000;
//new char[s];
}
{
using namespace test2007_5_15_1;
S s;
//gf((&s)->*(S::f));
Common c;
//(c->*(S::f))(1);
}
{
using namespace test2007_5_18_1;
#define
M1(x) x
int ii = M1((T<1,2,3,4,5>::i()));
#undef
M1
int i = 0;
}
{
typedef int T;
typedef int T;
//typedef long T; // C2371:
“T” : 重定义;不同的基类型
{
typedef long T;
}
}
{
typedef const const int CINT;
typedef const const const const const const const const const const const const const int CINT;
}
{
class A
{
public:
void f(int){};
virtual void f(){};
};
class B : public A
{
public:
virtual void f(){};
};
B b;
void (A::*_f)(int) = A::f;
(b.*_f)(1);
(b.*(void (A::*)(int))A::f)(1);
}
{
class EB {};
class E : public EB {};
class E2 : public EB {};
try
{
try
{
throw E2();
}
catch(E2 e)
{
int i = 0;
}
catch(EB e)
{
int i = 0;
}
}
catch(...)
{
int i = 0;
}
}
{
class A
{
class B;
};
//class A::B{}:
}
{
class A
{
char fill[0x100];
};
class B{};
class C : A, public B{};
C* c = 0;
B* b = c; // b -> 0
c = reinterpret_cast<C*>(0x1);
b = c; // b -> 0x101
int i = 0;
}
{
struct A
{
virtual int operator + (int){return 0;};
};
struct B : public A
{
virtual int operator + (int){return 1;};
};
B b;
A* a = &b;
int r = *a + 0;
int i = 0;
}
{
#define
REPEAT10(x) x x x x x x x x x x
#define
REPEAT100(x) /
REPEAT10(x) REPEAT10(x) REPEAT10(x) REPEAT10(x) REPEAT10(x) REPEAT10(x) REPEAT10(x) REPEAT10(x) REPEAT10(x) REPEAT10(x)
#define
REPEAT1000(x) /
REPEAT100(x) REPEAT100(x) REPEAT100(x) REPEAT100(x) REPEAT100(x) REPEAT100(x) REPEAT100(x) REPEAT100(x) REPEAT100(x) REPEAT100(x)
#define
REPEAT10000(x) /
REPEAT1000(x) REPEAT1000(x) REPEAT1000(x) REPEAT1000(x) REPEAT1000(x) REPEAT1000(x) REPEAT1000(x) REPEAT1000(x) REPEAT1000(x) REPEAT1000(x)
#define
REPEAT100000(x) /
REPEAT10000(x) REPEAT10000(x) REPEAT10000(x) REPEAT10000(x) REPEAT10000(x) REPEAT10000(x) REPEAT10000(x) REPEAT10000(x) REPEAT10000(x) REPEAT10000(x)
//int REPEAT10000(*) p10000; // C1026:
分析器堆栈溢出,程序太复杂
//int REPEAT1000(*) p1000; // error:
/*
fatal error LNK1000: Internal error during Pass2
Version 7.10.3077
ExceptionCode = C00000FD
ExceptionFlags = 00000000
ExceptionAddress = 1031F695 (10300000) "D:/Program Files/Microsoft Visual Studio .NET 2003/Common7/ide/mspdb71.dll"
NumberParameters = 00000002
ExceptionInformation[ 0] = 00000001
ExceptionInformation[ 1] = 00032FFC
CONTEXT:
Eax = 014AAA28 Esp = 00033000
Ebx = 000334B4 Ebp = 00033024
Ecx = 003AD618 Esi = 003AD618
Edx = 00033058 Edi = 0000158E
Eip = 1031F695 EFlags = 00010206
SegCs = 0000001B SegDs = 00000023
SegSs = 00000023 SegEs = 00000023
SegFs = 0000003B SegGs = 00000000
Dr0 = 00033000 Dr3 = 000334B4
Dr1 = 00033024 Dr6 = 003AD618
Dr2 = 00000000 Dr7 = 00000000
*/
int REPEAT100(*) REPEAT100(*) REPEAT100(*) REPEAT100(*) REPEAT100(*) REPEAT100(*) REPEAT100(*) REPEAT100(*) REPEAT100(*) REPEAT10(*) REPEAT10(*) ***** p925; // OK
//int REPEAT100(*) REPEAT100(*) REPEAT100(*) REPEAT100(*) REPEAT100(*) REPEAT100(*) REPEAT100(*) REPEAT100(*) REPEAT100(*) REPEAT10(*) REPEAT10(*) ****** p926; // LNK1000
int a100 REPEAT100([1]);
//int a1000 REPEAT1000([1]); // LNK1000: Internal error during Pass2
//int a100000 REPEAT100000([1]); // C1001:
内部编译器错误
#undef
REPEAT100000
#undef
REPEAT10000
#undef
REPEAT1000
#undef
REPEAT100
#undef
REPEAT10
}
{
struct A
{
int m[4][4];
};
typedef int (A::*A_int44_t)[4][4];
A_int44_t a_m = &A::m;
A a;
(a.*a_m)[0][0] = 0;
}
{
char c = 1i8;
short s = 1i16;
int i = 1i32;
int I = 1I32;
long l = 1l;
long L = 1L;
long ul = 1ul;
long UL = 1UL;
long uL = 1uL;
long Ul = 1Ul;
long long ll = 1i64;
//unsigned __int64 i128 = 0x1ui128; // C2059:
语法错误 : “数字上的错误后缀”
#ifdef
_LONGLONG
# error
#endif
}
{
#define
SR2(x) x##x
#define
SR4(x) SR2(x)##SR2(x)
#define
SR10(x) x##x##x##x##x##x##x##x##x##x
#define
SR100(x) SR10(x)##SR10(x)##SR10(x)##SR10(x)##SR10(x)##SR10(x)##SR10(x)##SR10(x)##SR10(x)##SR10(x)
#define
SR1000(x) SR100(x)##SR100(x)##SR100(x)##SR100(x)##SR100(x)##SR100(x)##SR100(x)##SR100(x)##SR100(x)##SR100(x)
#define
SR10000(x) SR1000(x)##SR1000(x)##SR1000(x)##SR1000(x)##SR1000(x)##SR1000(x)##SR1000(x)##SR1000(x)##SR1000(x)##SR1000(x)
int SR4(_) = 0;
____ = 1;
int SR10(_) = 0;
int SR100(_) = 0;
int SR1000(_) = 0;
//int SR10000(_) = 0; // C1064:
编译器限制 : 标记已溢出内部缓冲区
________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ = 1;
#undef
SR10000
#undef
SR1000
#undef
SR100
#undef
SR10
#undef
SR4
#undef
SR2
}
}
以上代码在VC7.1上可以编译通过。