summaryrefslogtreecommitdiff
blob: a362e74946361e76a0efae46e765d12a23023a15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
Subject: Aliasing violation causes erroneous output in GCC 4.4.4
Origin, upstream, http://code.google.com/p/nvidia-texture-tools/source/detail?r=1167
Bug: http://code.google.com/p/nvidia-texture-tools/issues/detail?id=139

Index: src/src/nvmath/Vector.h
===================================================================
--- src/src/nvmath/Vector.h	(revision 8311)
+++ src/src/nvmath/Vector.h	(working copy)
@@ -68,7 +68,7 @@
 	scalar y() const;
 	scalar z() const;
 
-	const Vector2 & xy() const;
+	Vector2 xy() const;
 
 	scalar component(uint idx) const;
 
@@ -111,8 +111,8 @@
 	scalar z() const;
 	scalar w() const;
 	
-	const Vector2 & xy() const;
-	const Vector3 & xyz() const;
+	Vector2 xy() const;
+	Vector3 xyz() const;
 
 	scalar component(uint idx) const;
 
@@ -231,9 +231,9 @@
 inline scalar Vector3::y() const { return m_y; }
 inline scalar Vector3::z() const { return m_z; }
 	
-inline const Vector2 & Vector3::xy() const
+inline Vector2 Vector3::xy() const
 {
-	return *(Vector2 *)this;
+	return Vector2(m_x, m_y);
 }
 
 inline scalar Vector3::component(uint idx) const
@@ -332,14 +332,14 @@
 inline scalar Vector4::z() const { return m_z; }
 inline scalar Vector4::w() const { return m_w; }
 
-inline const Vector2 & Vector4::xy() const
+inline Vector2 Vector4::xy() const
 {
-	return *(Vector2 *)this;
+	return Vector2(m_x, m_y);
 }
 
-inline const Vector3 & Vector4::xyz() const
+inline Vector3 Vector4::xyz() const
 {
-	return *(Vector3 *)this;
+	return Vector3(m_x, m_y, m_z);
 }
 
 inline scalar Vector4::component(uint idx) const