bug_ms_vec_static.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. enum precision
  2. {
  3. packed_highp,
  4. packed_mediump,
  5. packed_lowp,
  6. aligned_highp,
  7. aligned_mediump,
  8. aligned_lowp,
  9. aligned = aligned_highp,
  10. highp = packed_highp,
  11. mediump = packed_mediump,
  12. lowp = packed_lowp,
  13. packed = packed_highp,
  14. defaultp = highp
  15. };
  16. template<typename T, precision P = defaultp> struct vec2;
  17. template<typename T>
  18. struct _swizzle_base0
  19. {
  20. char _buffer[1];
  21. };
  22. template<typename T, precision P, int E0, int E1, int E2, int E3>
  23. struct _swizzle_base1 : public _swizzle_base0<T>
  24. {
  25. };
  26. template<typename T, precision P, int E0, int E1>
  27. struct _swizzle_base1<T, P, E0,E1,-1,-2> : public _swizzle_base0<T>
  28. {
  29. };
  30. template<typename T, precision P, int E0, int E1, int E2, int E3, int DUPLICATE_ELEMENTS>
  31. struct _swizzle_base2 : public _swizzle_base1<T, P, E0,E1,E2,E3>
  32. {
  33. };
  34. template<typename T, precision P, int E0, int E1, int E2, int E3>
  35. struct _swizzle_base2<T, P, E0,E1,E2,E3, 1> : public _swizzle_base1<T, P, E0,E1,E2,E3>
  36. {
  37. };
  38. template<typename T, precision P, int E0, int E1, int E2, int E3>
  39. struct _swizzle : public _swizzle_base2<T, P, E0, E1, E2, E3, (E0 == E1 || E0 == E2 || E0 == E3 || E1 == E2 || E1 == E3 || E2 == E3)>
  40. {
  41. };
  42. template<typename T, precision P>
  43. struct vec2
  44. {
  45. constexpr vec2(T x, T y) :
  46. x(x), y(y)
  47. {}
  48. union
  49. {
  50. struct { T x, y; };
  51. struct { _swizzle<T, P, 0,0,-1,-2> xx; };
  52. };
  53. };
  54. typedef vec2<float, defaultp> float2;
  55. // Visual C++ has a bug generating the error: fatal error C1001: An internal error has occurred in the compiler.
  56. float2 const Bar(1.f, 1.f);
  57. int main()
  58. {
  59. return 0;
  60. }