From 289b6abb43565185a342a2d6b0a3cfea9a977be0 Mon Sep 17 00:00:00 2001 From: Raphael Kubo da Costa Date: Mon, 29 Apr 2013 23:56:07 +0300 Subject: [PATCH] Correctly initialize std::mbstate_t. mbstate_t is an opaque type that is often a union or a struct, so setting it directly to 0 is incorrect and causes build failures with some compilers such as clang. --- taglib/toolkit/tstring.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/taglib/toolkit/tstring.cpp b/taglib/toolkit/tstring.cpp index 392f32ed..eaf5291e 100644 --- a/taglib/toolkit/tstring.cpp +++ b/taglib/toolkit/tstring.cpp @@ -78,9 +78,10 @@ namespace char *dstBegin = dst; char *dstEnd = dstBegin + dstLength; - std::mbstate_t st = 0; + std::mbstate_t st; const wchar_t *source; char *target; + memset(&st, 0, sizeof(st)); std::codecvt_base::result result = utf8_utf16_t().out( st, srcBegin, srcEnd, source, dstBegin, dstEnd, target); @@ -123,9 +124,10 @@ namespace wchar_t *dstBegin = dst; wchar_t *dstEnd = dstBegin + dstLength; - std::mbstate_t st = 0; + std::mbstate_t st; const char *source; wchar_t *target; + memset(&st, 0, sizeof(st)); std::codecvt_base::result result = utf8_utf16_t().in( st, srcBegin, srcEnd, source, dstBegin, dstEnd, target);