On October 18, 2017 10:18:11 PM Matt Turner <[email protected]> wrote:

On Fri, Sep 29, 2017 at 2:25 PM, Jason Ekstrand <[email protected]> wrote:
diff --git a/src/mesa/drivers/dri/i965/gen6_constant_state.c b/src/mesa/drivers/dri/i965/gen6_constant_state.c
index b2e357f..93a12c7 100644
--- a/src/mesa/drivers/dri/i965/gen6_constant_state.c
+++ b/src/mesa/drivers/dri/i965/gen6_constant_state.c
@@ -24,21 +24,84 @@
 #include "brw_context.h"
 #include "brw_state.h"
 #include "brw_defines.h"
+#include "brw_program.h"
 #include "intel_batchbuffer.h"
 #include "intel_buffer_objects.h"
 #include "program/prog_parameter.h"

+static uint32_t
+f_as_u32(float f)
+{
+   return *(uint32_t *)&f;
+}

PSA: This breaks C's aliasing rules and is not allowed in Mesa. GCC
warns about this, at least when optimizing.

I've pushed a trivial patch that uses a union instead:

-   return *(uint32_t *)&f;
+   union fi fi = { .f = f };
+   return fi.ui;

Hmm, I wonder why I didn't see that warning. Maybe because I'm building with clang these days? In any case, thanks for fixing it.


_______________________________________________
mesa-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to