Skip to content

Commit

Permalink
Resolve aliasing issues #152, #212
Browse files Browse the repository at this point in the history
  • Loading branch information
Christophe Riccio committed Jun 21, 2014
1 parent 381e162 commit b69356c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
20 changes: 17 additions & 3 deletions glm/gtc/packing.inl
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ namespace detail
# if(GLM_COMPILER & GLM_COMPILER_GCC || GLM_COMPILER & GLM_COMPILER_CLANG)
float Temp = 0;
memcpy(&Temp, &Result, sizeof(Temp));
return Temp;
# else
return reinterpret_cast<float&>(Result);
# endif
Expand All @@ -184,7 +185,13 @@ namespace detail
else if(glm::isinf(x))
return 0x1f << 5;

uint Pack = reinterpret_cast<uint&>(x);
# if(GLM_COMPILER & GLM_COMPILER_GCC || GLM_COMPILER & GLM_COMPILER_CLANG)
uint Pack = 0;
memcpy(&Pack, &x, sizeof(Pack));
# else
uint Pack = reinterpret_cast<uint&>(x);
# endif

return float2packed10(Pack);
}

Expand All @@ -197,8 +204,15 @@ namespace detail
else if(x == (0x1f << 5))
return ~0;//Inf

uint result = packed10ToFloat(x);
return reinterpret_cast<float&>(result);
uint Result = packed10ToFloat(x);

# if(GLM_COMPILER & GLM_COMPILER_GCC || GLM_COMPILER & GLM_COMPILER_CLANG)
float Temp = 0;
memcpy(&Temp, &Result, sizeof(Temp));
return Temp;
# else
return reinterpret_cast<float&>(Result);
# endif
}

// GLM_FUNC_QUALIFIER glm::uint f11_f11_f10(float x, float y, float z)
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ GLM 0.9.5.4: 2014-0X-XX
- Fixed tweakedInfinitePerspective #208 and added user-defined epsilon to
tweakedInfinitePerspective
- Fixed std::copy and std::vector with GLM types #214
- Fixed aliasing issues #212, #152

================================================================================
GLM 0.9.5.3: 2014-04-02
Expand Down

0 comments on commit b69356c

Please sign in to comment.