bug_ms_vec_static.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. template<typename T> struct vec2;
  2. struct _swizzle_base0
  3. {
  4. char _buffer[1];
  5. };
  6. template<int E0, int E1, int E2, int E3>
  7. struct _swizzle_base1 : public _swizzle_base0
  8. {
  9. };
  10. template<int E0, int E1>
  11. struct _swizzle_base1<E0,E1,-1,-2> : public _swizzle_base0
  12. {
  13. };
  14. template<int E0, int E1, int E2, int E3, int DUPLICATE_ELEMENTS>
  15. struct _swizzle_base2 : public _swizzle_base1<E0,E1,E2,E3>
  16. {
  17. };
  18. template<int E0, int E1, int E2, int E3>
  19. struct _swizzle_base2<E0,E1,E2,E3, 1> : public _swizzle_base1<E0,E1,E2,E3>
  20. {
  21. };
  22. template<int E0, int E1, int E2, int E3>
  23. struct _swizzle : public _swizzle_base2<E0, E1, E2, E3, (E0 == E1 || E0 == E2 || E0 == E3 || E1 == E2 || E1 == E3 || E2 == E3)>
  24. {
  25. };
  26. template<typename T>
  27. struct vec2
  28. {
  29. constexpr vec2(T x, T y) :
  30. x(x), y(y)
  31. {}
  32. union
  33. {
  34. struct { T x, y; };
  35. struct { _swizzle<0,0,-1,-2> xx; };
  36. };
  37. };
  38. typedef vec2<float> float2;
  39. // Visual C++ has a bug generating the error: fatal error C1001: An internal error has occurred in the compiler.
  40. float2 const Bar(1.f, 1.f);
  41. int main()
  42. {
  43. return 0;
  44. }