summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatt Turner <[email protected]>2016-05-26 15:53:58 -0700
committerMatt Turner <[email protected]>2016-07-26 12:12:27 -0700
commit2a1d2874f1f98a41d62174091cb3c303c120ca3d (patch)
tree6d8eb1e82cfe757fdc13b752d274b9ad16a68153 /src
parentf5ac1d366e81ee9ad11f44ee64a5b556bc6f1989 (diff)
mesa: Avoid aliasing violation in uniform_query.cpp.
Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/mesa/main/uniform_query.cpp45
1 files changed, 31 insertions, 14 deletions
diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
index b9b9ff23ffa..9caf5e19766 100644
--- a/src/mesa/main/uniform_query.cpp
+++ b/src/mesa/main/uniform_query.cpp
@@ -382,9 +382,12 @@ _mesa_get_uniform(struct gl_context *ctx, GLuint program, GLint location,
case GLSL_TYPE_BOOL:
dst[didx].f = src[sidx].i ? 1.0f : 0.0f;
break;
- case GLSL_TYPE_DOUBLE:
- dst[didx].f = *(double *)&src[sidx].f;
+ case GLSL_TYPE_DOUBLE: {
+ double tmp;
+ memcpy(&tmp, &src[sidx].f, sizeof(tmp));
+ dst[didx].f = tmp;
break;
+ }
default:
assert(!"Should not get here.");
break;
@@ -392,20 +395,28 @@ _mesa_get_uniform(struct gl_context *ctx, GLuint program, GLint location,
break;
case GLSL_TYPE_DOUBLE:
switch (uni->type->base_type) {
- case GLSL_TYPE_UINT:
- *(double *)&dst[didx].f = (double) src[sidx].u;
+ case GLSL_TYPE_UINT: {
+ double tmp = src[sidx].u;
+ memcpy(&dst[didx].f, &tmp, sizeof(tmp));
break;
+ }
case GLSL_TYPE_INT:
case GLSL_TYPE_SAMPLER:
- case GLSL_TYPE_IMAGE:
- *(double *)&dst[didx].f = (double) src[sidx].i;
+ case GLSL_TYPE_IMAGE: {
+ double tmp = src[sidx].i;
+ memcpy(&dst[didx].f, &tmp, sizeof(tmp));
break;
- case GLSL_TYPE_BOOL:
- *(double *)&dst[didx].f = src[sidx].i ? 1.0f : 0.0f;
+ }
+ case GLSL_TYPE_BOOL: {
+ double tmp = src[sidx].i ? 1.0 : 0.0;
+ memcpy(&dst[didx].f, &tmp, sizeof(tmp));
break;
- case GLSL_TYPE_FLOAT:
- *(double *)&dst[didx].f = (double) src[sidx].f;
+ }
+ case GLSL_TYPE_FLOAT: {
+ double tmp = src[sidx].f;
+ memcpy(&dst[didx].f, &tmp, sizeof(tmp));
break;
+ }
default:
assert(!"Should not get here.");
break;
@@ -437,9 +448,12 @@ _mesa_get_uniform(struct gl_context *ctx, GLuint program, GLint location,
case GLSL_TYPE_BOOL:
dst[didx].i = src[sidx].i ? 1 : 0;
break;
- case GLSL_TYPE_DOUBLE:
- dst[didx].i = IROUNDD(*(double *)&src[sidx].f);
+ case GLSL_TYPE_DOUBLE: {
+ double tmp;
+ memcpy(&tmp, &src[sidx].f, sizeof(tmp));
+ dst[didx].i = IROUNDD(tmp);
break;
+ }
default:
assert(!"Should not get here.");
break;
@@ -486,9 +500,12 @@ log_uniform(const void *values, enum glsl_base_type basicType,
case GLSL_TYPE_FLOAT:
printf("%g ", v[i].f);
break;
- case GLSL_TYPE_DOUBLE:
- printf("%g ", *(double* )&v[i * 2].f);
+ case GLSL_TYPE_DOUBLE: {
+ double tmp;
+ memcpy(&tmp, &v[i * 2].f, sizeof(tmp));
+ printf("%g ", tmp);
break;
+ }
default:
assert(!"Should not get here.");
break;