[Mesa-dev] [PATCH] tgsi: fix rbug compile error
Jose Fonseca
jfonseca at vmware.com
Sat Dec 11 04:22:02 PST 2010
Looks good to me FWIW.
Usually one uses a union for avoid breaking strict-aliasing rules, but your memcpy approach should produce just as good code with less typing.
The only proper fix here would be to make struct tgsi_token an union of all possible token types.
Jose
________________________________________
From: mesa-dev-bounces+jfonseca=vmware.com at lists.freedesktop.org [mesa-dev-bounces+jfonseca=vmware.com at lists.freedesktop.org] On Behalf Of Marek Olšák [maraeo at gmail.com]
Sent: Saturday, December 11, 2010 8:04
To: mesa-dev at lists.freedesktop.org
Subject: [Mesa-dev] [PATCH] tgsi: fix rbug compile error
../mesa/src/gallium/auxiliary/tgsi/tgsi_parse.h:139:
error: dereferencing pointer ‘tokens.25’ does break strict-aliasing rules
Signed-off-by: Marek Olšák <maraeo at gmail.com>
---
src/gallium/auxiliary/tgsi/tgsi_parse.h | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/src/gallium/auxiliary/tgsi/tgsi_parse.h b/src/gallium/auxiliary/tgsi/tgsi_parse.h
index d4df585..2aafa2a 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_parse.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_parse.h
@@ -136,7 +136,8 @@ tgsi_parse_token(
static INLINE unsigned
tgsi_num_tokens(const struct tgsi_token *tokens)
{
- struct tgsi_header header = *(const struct tgsi_header *) tokens;
+ struct tgsi_header header;
+ memcpy(&header, tokens, sizeof(header));
return header.HeaderSize + header.BodySize;
}
--
1.7.1
_______________________________________________
mesa-dev mailing list
mesa-dev at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list