The default bug view has changed. See this FAQ.

Silence the clang warnings issued because of alignment requirements increase when compiling mfbt/Util.h

RESOLVED FIXED in mozilla7

Status

()

Core
JavaScript Engine
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: Ehsan, Assigned: Ehsan)

Tracking

unspecified
mozilla7
x86
Mac OS X
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [fixed-in-tracemonkey])

Attachments

(1 attachment)

(Assignee)

Description

6 years ago
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)
               ^
(Assignee)

Comment 1

6 years ago
Created attachment 538144 [details] [diff] [review]
Patch (v1)
Assignee: general → ehsan
Status: NEW → ASSIGNED
Attachment #538144 - Flags: review?(jwalden+bmo)
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.
Attachment #538144 - Flags: review?(jwalden+bmo) → review+
(Assignee)

Comment 3

6 years ago
No, unfortunately simply using reinterpret_cast doesn't tell the compiler to ignore alignment requirements.  It only bypasses the type system.
(Assignee)

Comment 4

6 years ago
http://hg.mozilla.org/tracemonkey/rev/6408e5021891
Whiteboard: [fixed-in-tracemonkey]
Target Milestone: --- → mozilla7
cdleary-bot mozilla-central merge info:
http://hg.mozilla.org/mozilla-central/rev/6408e5021891
Status: ASSIGNED → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.