Skip to content

Commit

Permalink
Fixed memory corruption (undefined behaviour) #303
Browse files Browse the repository at this point in the history
  • Loading branch information
Christophe Riccio committed Feb 14, 2015
1 parent f1d4c39 commit 7844332
Show file tree
Hide file tree
Showing 25 changed files with 430 additions and 278 deletions.
3 changes: 3 additions & 0 deletions glm/detail/type_mat2x2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ namespace glm
//////////////////////////////////////
// Constructors
GLM_FUNC_DECL tmat2x2();
GLM_FUNC_DECL tmat2x2(tmat2x2<T, P> const & m);
template <precision Q>
GLM_FUNC_DECL tmat2x2(tmat2x2<T, Q> const & m);

Expand Down Expand Up @@ -127,6 +128,8 @@ namespace glm
//////////////////////////////////////
// Unary arithmetic operators

GLM_FUNC_DECL tmat2x2<T, P> & operator=(tmat2x2<T, P> const & v);

template <typename U>
GLM_FUNC_DECL tmat2x2<T, P> & operator=(tmat2x2<U, P> const & m);
template <typename U>
Expand Down
15 changes: 15 additions & 0 deletions glm/detail/type_mat2x2.inl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ namespace detail
# endif
}

template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x2<T, P>::tmat2x2(tmat2x2<T, P> const & m)
{
this->value[0] = m.value[0];
this->value[1] = m.value[1];
}

template <typename T, precision P>
template <precision Q>
GLM_FUNC_QUALIFIER tmat2x2<T, P>::tmat2x2(tmat2x2<T, Q> const & m)
Expand Down Expand Up @@ -236,6 +243,14 @@ namespace detail
//////////////////////////////////////////////////////////////
// Unary updatable operators

template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x2<T, P>& tmat2x2<T, P>::operator=(tmat2x2<T, P> const & m)
{
this->value[0] = m[0];
this->value[1] = m[1];
return *this;
}

template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tmat2x2<T, P>& tmat2x2<T, P>::operator=(tmat2x2<U, P> const & m)
Expand Down
72 changes: 24 additions & 48 deletions glm/detail/type_mat2x3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ namespace glm
public:
// Constructors
GLM_FUNC_DECL tmat2x3();
GLM_FUNC_DECL tmat2x3(tmat2x3<T, P> const & m);
template <precision Q>
GLM_FUNC_DECL tmat2x3(tmat2x3<T, Q> const & m);

Expand Down Expand Up @@ -123,20 +124,22 @@ namespace glm
//////////////////////////////////////
// Unary arithmetic operators

GLM_FUNC_DECL tmat2x3<T, P> & operator=(tmat2x3<T, P> const & m);

template <typename U>
GLM_FUNC_DECL tmat2x3<T, P> & operator= (tmat2x3<U, P> const & m);
GLM_FUNC_DECL tmat2x3<T, P> & operator=(tmat2x3<U, P> const & m);
template <typename U>
GLM_FUNC_DECL tmat2x3<T, P> & operator+= (U s);
GLM_FUNC_DECL tmat2x3<T, P> & operator+=(U s);
template <typename U>
GLM_FUNC_DECL tmat2x3<T, P> & operator+= (tmat2x3<U, P> const & m);
GLM_FUNC_DECL tmat2x3<T, P> & operator+=(tmat2x3<U, P> const & m);
template <typename U>
GLM_FUNC_DECL tmat2x3<T, P> & operator-= (U s);
GLM_FUNC_DECL tmat2x3<T, P> & operator-=(U s);
template <typename U>
GLM_FUNC_DECL tmat2x3<T, P> & operator-= (tmat2x3<U, P> const & m);
GLM_FUNC_DECL tmat2x3<T, P> & operator-=(tmat2x3<U, P> const & m);
template <typename U>
GLM_FUNC_DECL tmat2x3<T, P> & operator*= (U s);
GLM_FUNC_DECL tmat2x3<T, P> & operator*=(U s);
template <typename U>
GLM_FUNC_DECL tmat2x3<T, P> & operator/= (U s);
GLM_FUNC_DECL tmat2x3<T, P> & operator/=(U s);

//////////////////////////////////////
// Increment and decrement operators
Expand All @@ -150,74 +153,47 @@ namespace glm
// Binary operators

template <typename T, precision P>
GLM_FUNC_DECL tmat2x3<T, P> operator+ (
tmat2x3<T, P> const & m,
T const & s);
GLM_FUNC_DECL tmat2x3<T, P> operator+(tmat2x3<T, P> const & m, T const & s);

template <typename T, precision P>
GLM_FUNC_DECL tmat2x3<T, P> operator+ (
tmat2x3<T, P> const & m1,
tmat2x3<T, P> const & m2);
GLM_FUNC_DECL tmat2x3<T, P> operator+(tmat2x3<T, P> const & m1, tmat2x3<T, P> const & m2);

template <typename T, precision P>
GLM_FUNC_DECL tmat2x3<T, P> operator- (
tmat2x3<T, P> const & m,
T const & s);
GLM_FUNC_DECL tmat2x3<T, P> operator-(tmat2x3<T, P> const & m, T const & s);

template <typename T, precision P>
GLM_FUNC_DECL tmat2x3<T, P> operator- (
tmat2x3<T, P> const & m1,
tmat2x3<T, P> const & m2);
GLM_FUNC_DECL tmat2x3<T, P> operator-(tmat2x3<T, P> const & m1, tmat2x3<T, P> const & m2);

template <typename T, precision P>
GLM_FUNC_DECL tmat2x3<T, P> operator* (
tmat2x3<T, P> const & m,
T const & s);
GLM_FUNC_DECL tmat2x3<T, P> operator*(tmat2x3<T, P> const & m, T const & s);

template <typename T, precision P>
GLM_FUNC_DECL tmat2x3<T, P> operator* (
T const & s,
tmat2x3<T, P> const & m);
GLM_FUNC_DECL tmat2x3<T, P> operator*(T const & s, tmat2x3<T, P> const & m);

template <typename T, precision P>
GLM_FUNC_DECL typename tmat2x3<T, P>::col_type operator* (
tmat2x3<T, P> const & m,
typename tmat2x3<T, P>::row_type const & v);
GLM_FUNC_DECL typename tmat2x3<T, P>::col_type operator*(tmat2x3<T, P> const & m, typename tmat2x3<T, P>::row_type const & v);

template <typename T, precision P>
GLM_FUNC_DECL typename tmat2x3<T, P>::row_type operator* (
typename tmat2x3<T, P>::col_type const & v,
tmat2x3<T, P> const & m);
GLM_FUNC_DECL typename tmat2x3<T, P>::row_type operator*(typename tmat2x3<T, P>::col_type const & v, tmat2x3<T, P> const & m);

template <typename T, precision P>
GLM_FUNC_DECL tmat2x3<T, P> operator* (
tmat2x3<T, P> const & m1,
tmat2x2<T, P> const & m2);
GLM_FUNC_DECL tmat2x3<T, P> operator*(tmat2x3<T, P> const & m1, tmat2x2<T, P> const & m2);

template <typename T, precision P>
GLM_FUNC_DECL tmat3x3<T, P> operator* (
tmat2x3<T, P> const & m1,
tmat3x2<T, P> const & m2);
GLM_FUNC_DECL tmat3x3<T, P> operator*(tmat2x3<T, P> const & m1, tmat3x2<T, P> const & m2);

template <typename T, precision P>
GLM_FUNC_DECL tmat4x3<T, P> operator* (
tmat2x3<T, P> const & m1,
tmat4x2<T, P> const & m2);
GLM_FUNC_DECL tmat4x3<T, P> operator*(tmat2x3<T, P> const & m1, tmat4x2<T, P> const & m2);

template <typename T, precision P>
GLM_FUNC_DECL tmat2x3<T, P> operator/ (
tmat2x3<T, P> const & m,
T const & s);
GLM_FUNC_DECL tmat2x3<T, P> operator/(tmat2x3<T, P> const & m, T const & s);

template <typename T, precision P>
GLM_FUNC_DECL tmat2x3<T, P> operator/ (
T const & s,
tmat2x3<T, P> const & m);
GLM_FUNC_DECL tmat2x3<T, P> operator/(T const & s, tmat2x3<T, P> const & m);

// Unary constant operators
template <typename T, precision P>
GLM_FUNC_DECL tmat2x3<T, P> const operator- (
tmat2x3<T, P> const & m);
GLM_FUNC_DECL tmat2x3<T, P> const operator-(tmat2x3<T, P> const & m);
}//namespace glm

#ifndef GLM_EXTERNAL_TEMPLATE
Expand Down
15 changes: 15 additions & 0 deletions glm/detail/type_mat2x3.inl
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ namespace glm
# endif
}

template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x3<T, P>::tmat2x3(tmat2x3<T, P> const & m)
{
this->value[0] = m.value[0];
this->value[1] = m.value[1];
}

template <typename T, precision P>
template <precision Q>
GLM_FUNC_QUALIFIER tmat2x3<T, P>::tmat2x3(tmat2x3<T, Q> const & m)
Expand Down Expand Up @@ -220,6 +227,14 @@ namespace glm
//////////////////////////////////////////////////////////////
// Unary updatable operators

template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x3<T, P>& tmat2x3<T, P>::operator=(tmat2x3<T, P> const & m)
{
this->value[0] = m[0];
this->value[1] = m[1];
return *this;
}

template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tmat2x3<T, P>& tmat2x3<T, P>::operator=(tmat2x3<U, P> const & m)
Expand Down
74 changes: 25 additions & 49 deletions glm/detail/type_mat2x4.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ namespace glm
public:
// Constructors
GLM_FUNC_DECL tmat2x4();
GLM_FUNC_DECL tmat2x4(tmat2x4<T, P> const & m);
template <precision Q>
GLM_FUNC_DECL tmat2x4(tmat2x4<T, Q> const & m);

Expand Down Expand Up @@ -124,20 +125,22 @@ namespace glm
//////////////////////////////////////
// Unary arithmetic operators

GLM_FUNC_DECL tmat2x4<T, P> & operator=(tmat2x4<T, P> const & m);

template <typename U>
GLM_FUNC_DECL tmat2x4<T, P>& operator= (tmat2x4<U, P> const & m);
GLM_FUNC_DECL tmat2x4<T, P> & operator=(tmat2x4<U, P> const & m);
template <typename U>
GLM_FUNC_DECL tmat2x4<T, P>& operator+= (U s);
GLM_FUNC_DECL tmat2x4<T, P> & operator+=(U s);
template <typename U>
GLM_FUNC_DECL tmat2x4<T, P>& operator+= (tmat2x4<U, P> const & m);
GLM_FUNC_DECL tmat2x4<T, P> & operator+=(tmat2x4<U, P> const & m);
template <typename U>
GLM_FUNC_DECL tmat2x4<T, P>& operator-= (U s);
GLM_FUNC_DECL tmat2x4<T, P> & operator-=(U s);
template <typename U>
GLM_FUNC_DECL tmat2x4<T, P>& operator-= (tmat2x4<U, P> const & m);
GLM_FUNC_DECL tmat2x4<T, P> & operator-=(tmat2x4<U, P> const & m);
template <typename U>
GLM_FUNC_DECL tmat2x4<T, P>& operator*= (U s);
GLM_FUNC_DECL tmat2x4<T, P> & operator*=(U s);
template <typename U>
GLM_FUNC_DECL tmat2x4<T, P>& operator/= (U s);
GLM_FUNC_DECL tmat2x4<T, P> & operator/=(U s);

//////////////////////////////////////
// Increment and decrement operators
Expand All @@ -151,74 +154,47 @@ namespace glm
// Binary operators

template <typename T, precision P>
GLM_FUNC_DECL tmat2x4<T, P> operator+ (
tmat2x4<T, P> const & m,
T const & s);
GLM_FUNC_DECL tmat2x4<T, P> operator+(tmat2x4<T, P> const & m, T const & s);

template <typename T, precision P>
GLM_FUNC_DECL tmat2x4<T, P> operator+ (
tmat2x4<T, P> const & m1,
tmat2x4<T, P> const & m2);
GLM_FUNC_DECL tmat2x4<T, P> operator+(tmat2x4<T, P> const & m1, tmat2x4<T, P> const & m2);

template <typename T, precision P>
GLM_FUNC_DECL tmat2x4<T, P> operator- (
tmat2x4<T, P> const & m,
T const & s);
GLM_FUNC_DECL tmat2x4<T, P> operator-(tmat2x4<T, P> const & m, T const & s);

template <typename T, precision P>
GLM_FUNC_DECL tmat2x4<T, P> operator- (
tmat2x4<T, P> const & m1,
tmat2x4<T, P> const & m2);
GLM_FUNC_DECL tmat2x4<T, P> operator-(tmat2x4<T, P> const & m1, tmat2x4<T, P> const & m2);

template <typename T, precision P>
GLM_FUNC_DECL tmat2x4<T, P> operator* (
tmat2x4<T, P> const & m,
T const & s);
GLM_FUNC_DECL tmat2x4<T, P> operator*(tmat2x4<T, P> const & m, T const & s);

template <typename T, precision P>
GLM_FUNC_DECL tmat2x4<T, P> operator* (
T const & s,
tmat2x4<T, P> const & m);
GLM_FUNC_DECL tmat2x4<T, P> operator*(T const & s, tmat2x4<T, P> const & m);

template <typename T, precision P>
GLM_FUNC_DECL typename tmat2x4<T, P>::col_type operator* (
tmat2x4<T, P> const & m,
typename tmat2x4<T, P>::row_type const & v);
GLM_FUNC_DECL typename tmat2x4<T, P>::col_type operator*(tmat2x4<T, P> const & m, typename tmat2x4<T, P>::row_type const & v);

template <typename T, precision P>
GLM_FUNC_DECL typename tmat2x4<T, P>::row_type operator* (
typename tmat2x4<T, P>::col_type const & v,
tmat2x4<T, P> const & m);
GLM_FUNC_DECL typename tmat2x4<T, P>::row_type operator*(typename tmat2x4<T, P>::col_type const & v, tmat2x4<T, P> const & m);

template <typename T, precision P>
GLM_FUNC_DECL tmat4x4<T, P> operator* (
tmat2x4<T, P> const & m1,
tmat4x2<T, P> const & m2);
GLM_FUNC_DECL tmat4x4<T, P> operator*(tmat2x4<T, P> const & m1, tmat4x2<T, P> const & m2);

template <typename T, precision P>
GLM_FUNC_DECL tmat2x4<T, P> operator* (
tmat2x4<T, P> const & m1,
tmat2x2<T, P> const & m2);

GLM_FUNC_DECL tmat2x4<T, P> operator*(tmat2x4<T, P> const & m1, tmat2x2<T, P> const & m2);

template <typename T, precision P>
GLM_FUNC_DECL tmat3x4<T, P> operator* (
tmat2x4<T, P> const & m1,
tmat3x2<T, P> const & m2);
GLM_FUNC_DECL tmat3x4<T, P> operator*(tmat2x4<T, P> const & m1, tmat3x2<T, P> const & m2);

template <typename T, precision P>
GLM_FUNC_DECL tmat2x4<T, P> operator/ (
tmat2x4<T, P> const & m,
T s);
GLM_FUNC_DECL tmat2x4<T, P> operator/(tmat2x4<T, P> const & m, T s);

template <typename T, precision P>
GLM_FUNC_DECL tmat2x4<T, P> operator/ (
T s,
tmat2x4<T, P> const & m);
GLM_FUNC_DECL tmat2x4<T, P> operator/(T s, tmat2x4<T, P> const & m);

// Unary constant operators
template <typename T, precision P>
GLM_FUNC_DECL tmat2x4<T, P> const operator- (
tmat2x4<T, P> const & m);
GLM_FUNC_DECL tmat2x4<T, P> const operator-(tmat2x4<T, P> const & m);
}//namespace glm

#ifndef GLM_EXTERNAL_TEMPLATE
Expand Down
15 changes: 15 additions & 0 deletions glm/detail/type_mat2x4.inl
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ namespace glm
# endif
}

template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x4<T, P>::tmat2x4(tmat2x4<T, P> const & m)
{
this->value[0] = m.value[0];
this->value[1] = m.value[1];
}

template <typename T, precision P>
template <precision Q>
GLM_FUNC_QUALIFIER tmat2x4<T, P>::tmat2x4(tmat2x4<T, Q> const & m)
Expand Down Expand Up @@ -221,6 +228,14 @@ namespace glm
//////////////////////////////////////////////////////////////
// Unary updatable operators

template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x4<T, P>& tmat2x4<T, P>::operator=(tmat2x4<T, P> const & m)
{
this->value[0] = m[0];
this->value[1] = m[1];
return *this;
}

template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tmat2x4<T, P>& tmat2x4<T, P>::operator=(tmat2x4<U, P> const & m)
Expand Down
Loading

0 comments on commit 7844332

Please sign in to comment.