summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2012-04-11 21:27:17 (GMT)
committerChristian Mollekopf <chrigi_1@fastmail.fm>2012-04-11 21:27:17 (GMT)
commit7151c0b18cab919608d97a8490bdae480076bc9c (patch)
treee921c425bc6514f068f577d6679116d339ce290a
parent5d5a3c53f4a2a5a5c672f512b6ffea5a693d1231 (diff)
downloadlibkolabxml-7151c0b18cab919608d97a8490bdae480076bc9c.tar.gz
comply to strict aliasing rules
-rw-r--r--src/utils.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/utils.cpp b/src/utils.cpp
index 9cf2007..9249116 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -108,10 +108,11 @@ std::string getUID(const std::string &s)
return boost::uuids::to_string(u);
#else
uuid_t *uuid;
- char *str = 0;
+ //to avoid the "dereferencing type-punned pointer will break strict-aliasing rules" warning
+ char * __attribute__((__may_alias__)) str = 0;
uuid_create(&uuid);
uuid_make(uuid, UUID_MAKE_V1);
- uuid_export(uuid, UUID_FMT_STR, &str, 0);
+ uuid_export(uuid, UUID_FMT_STR, (void**)&str.v, 0);
uuid_destroy(uuid);
return std::string(str, 36); //We don't need the terminating \0