Closed Bug 662971 Opened 14 years ago Closed 14 years ago

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

Categories

(Core :: JavaScript Engine, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla7

People

(Reporter: ehsan.akhgari, Assigned: ehsan.akhgari)

Details

(Whiteboard: [fixed-in-tracemonkey])

Attachments

(1 file)

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) ^
Attached patch Patch (v1)Splinter Review
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+
No, unfortunately simply using reinterpret_cast doesn't tell the compiler to ignore alignment requirements. It only bypasses the type system.
Whiteboard: [fixed-in-tracemonkey]
Target Milestone: --- → mozilla7
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: