Bug 139222

Summary: Fix cast-align warning in StringImpl.h
Product: WebKit Reporter: Csaba Osztrogonác <ossy>
Component: New BugsAssignee: Csaba Osztrogonác <ossy>
Status: RESOLVED FIXED    
Severity: Normal CC: andersca, benjamin, cmarcelo, commit-queue, kling, ossy
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch none

Description Csaba Osztrogonác 2014-12-03 07:14:55 PST
Fix cast-align warning in StringImpl.h
Comment 1 Csaba Osztrogonác 2014-12-03 07:16:40 PST
warning log on ARM Linux build:

../../Source/WTF/wtf/text/StringImpl.h: In instantiation of ‘T* WTF::StringImpl::tailPointer() [with T = short unsigned int]’:
../../Source/WTF/wtf/text/StringImpl.h:182:39:   required from here
../../Source/WTF/wtf/text/StringImpl.h:749:87: warning: cast from ‘uint8_t* {aka unsigned char*}’ to ‘short unsigned int*’ increases required alignment of target type [-Wcast-align]
         return reinterpret_cast_ptr<T*>(reinterpret_cast<uint8_t*>(this) + tailOffset<T>());
                                                                                       ^
../../Source/WTF/wtf/text/StringImpl.h: In instantiation of ‘const T* WTF::StringImpl::tailPointer() const [with T = short unsigned int]’:
../../Source/WTF/wtf/text/StringImpl.h:720:47:   required from here
../../Source/WTF/wtf/text/StringImpl.h:743:99: warning: cast from ‘const uint8_t* {aka const unsigned char*}’ to ‘const short unsigned int*’ increases required alignment of target type [-Wcast-align]
         return reinterpret_cast_ptr<const T*>(reinterpret_cast<const uint8_t*>(this) + tailOffset<T>());
                                                                                                   ^
../../Source/WTF/wtf/text/StringImpl.h: In instantiation of ‘const T* WTF::StringImpl::tailPointer() const [with T = WTF::StringImpl*]’:
../../Source/WTF/wtf/text/StringImpl.h:756:42:   required from here
../../Source/WTF/wtf/text/StringImpl.h:743:99: warning: cast from ‘const uint8_t* {aka const unsigned char*}’ to ‘WTF::StringImpl* const*’ increases required alignment of target type [-Wcast-align]
../../Source/WTF/wtf/text/StringImpl.h: In instantiation of ‘T* WTF::StringImpl::tailPointer() [with T = WTF::StringImpl*]’:
../../Source/WTF/wtf/text/StringImpl.h:763:42:   required from here
../../Source/WTF/wtf/text/StringImpl.h:749:87: warning: cast from ‘uint8_t* {aka unsigned char*}’ to ‘WTF::StringImpl**’ increases required alignment of target type [-Wcast-align]
         return reinterpret_cast_ptr<T*>(reinterpret_cast<uint8_t*>(this) + tailOffset<T>());
                                                                                       ^


These casts are safe, tailOffset guarantees the alignment.
Comment 2 Csaba Osztrogonác 2014-12-03 07:18:07 PST
cc-ing Anders and Andreas, because https://trac.webkit.org/changeset/163341
touched these lines last time.
Comment 3 Csaba Osztrogonác 2014-12-03 07:18:14 PST
Created attachment 242490 [details]
Patch
Comment 4 WebKit Commit Bot 2014-12-04 11:22:10 PST
Comment on attachment 242490 [details]
Patch

Clearing flags on attachment: 242490

Committed r176805: <http://trac.webkit.org/changeset/176805>
Comment 5 WebKit Commit Bot 2014-12-04 11:22:14 PST
All reviewed patches have been landed.  Closing bug.