Last Comment Bug 662971 - Silence the clang warnings issued because of alignment requirements increase when compiling mfbt/Util.h
: Silence the clang warnings issued because of alignment requirements increase ...
Status: RESOLVED FIXED
[fixed-in-tracemonkey]
:
Product: Core
Classification: Components
Component: JavaScript Engine (show other bugs)
: unspecified
: x86 Mac OS X
: -- normal (vote)
: mozilla7
Assigned To: :Ehsan Akhgari
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-06-08 16:28 PDT by :Ehsan Akhgari
Modified: 2011-06-20 17:07 PDT (History)
1 user (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
Patch (v1) (1003 bytes, patch)
2011-06-08 16:28 PDT, :Ehsan Akhgari
jwalden+bmo: review+
Details | Diff | Splinter Review

Description :Ehsan Akhgari 2011-06-08 16:28:14 PDT
These warnings drive me nuts.  We get thousands of them when compiling mfbt/Util.h.

jscompartment.cpp
In file included from /Users/ehsanakhgari/moz/tmp/js/src/jscompartment.cpp:41:
In file included from /Users/ehsanakhgari/moz/tmp/js/src/jscntxt.h:48:
In file included from /Users/ehsanakhgari/moz/tmp/js/src/jsprvtd.h:57:
In file included from /Users/ehsanakhgari/moz/tmp/js/src/jspubtd.h:47:
In file included from /Users/ehsanakhgari/moz/tmp/js/src/jsval.h:48:
In file included from /Users/ehsanakhgari/moz/tmp/js/src/jsutil.h:48:
./../../dist/include/mozilla/Util.h:220:24: warning: cast from 'char *' to 'js::HashMap<JSFunction *, JSString *, js::DefaultHasher<JSFunction *>, js::SystemAllocPolicy>
      *' increases required alignment from 1 to 8 [-Wcast-align]
    T *addr() { return (T *)u.bytes; }
                       ^~~~~~~~~~~~
./../../dist/include/mozilla/Util.h:240:32: note: in instantiation of member function 'mozilla::AlignedStorage2<js::HashMap<JSFunction *, JSString *,
      js::DefaultHasher<JSFunction *>, js::SystemAllocPolicy> >::addr' requested here
    T &asT() { return *storage.addr(); }
                               ^
./../../dist/include/mozilla/Util.h:247:33: note: in instantiation of member function 'mozilla::Maybe<js::HashMap<JSFunction *, JSString *, js::DefaultHasher<JSFunction
      *>, js::SystemAllocPolicy> >::asT' requested here
    ~Maybe() { if (constructed) asT().~T(); }
                                ^
/Users/ehsanakhgari/moz/tmp/js/src/jscompartment.cpp:66:16: note: in instantiation of member function 'mozilla::Maybe<js::HashMap<JSFunction *, JSString *,
      js::DefaultHasher<JSFunction *>, js::SystemAllocPolicy> >::~Maybe' requested here
JSCompartment::JSCompartment(JSRuntime *rt)
               ^
Comment 1 :Ehsan Akhgari 2011-06-08 16:28:57 PDT
Created attachment 538144 [details] [diff] [review]
Patch (v1)
Comment 2 Jeff Walden [:Waldo] (remove +bmo to email) 2011-06-17 16:10:12 PDT
Comment on attachment 538144 [details] [diff] [review]
Patch (v1)

Does reinterpret_cast<T *>(u.bytes) avoid the problem?  Since that C++ cast is all "trust me, I know what I'm doing" I could imagine the warning might not happen for it.  If r_c<> silences the warning, use that.

But that's probably wishful thinking; if it doesn't work, this patch is perfectly fine.
Comment 3 :Ehsan Akhgari 2011-06-19 14:00:35 PDT
No, unfortunately simply using reinterpret_cast doesn't tell the compiler to ignore alignment requirements.  It only bypasses the type system.
Comment 4 :Ehsan Akhgari 2011-06-20 06:58:27 PDT
http://hg.mozilla.org/tracemonkey/rev/6408e5021891
Comment 5 Chris Leary [:cdleary] (not checking bugmail) 2011-06-20 17:07:03 PDT
cdleary-bot mozilla-central merge info:
http://hg.mozilla.org/mozilla-central/rev/6408e5021891

Note You need to log in before you can comment on or make changes to this bug.