Last Comment Bug 662964 - Silence the clang warnings issued because of alignment requirements increase when compiling jscntxt.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:20 PDT by :Ehsan Akhgari
Modified: 2011-06-20 17:06 PDT (History)
1 user (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


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

Description :Ehsan Akhgari 2011-06-08 16:20:59 PDT
These warnings drive me nuts.  We get thousands of them when compiling jscntxt.h.

jsapi.cpp
In file included from /Users/ehsanakhgari/moz/tmp/js/src/jsapi.cpp:61:
In file included from /Users/ehsanakhgari/moz/tmp/js/src/jsclone.h:43:
/Users/ehsanakhgari/moz/tmp/js/src/jscntxt.h:2279:12: warning: cast from 'uint8 *' (aka 'unsigned char *') to 'JSContext *' increases required alignment from 1 to 8
      [-Wcast-align]
    return (JSContext *) ((uint8 *) link - offsetof(JSContext, link));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Comment 1 :Ehsan Akhgari 2011-06-08 16:21:41 PDT
Created attachment 538142 [details] [diff] [review]
Patch (v1)
Comment 2 Jeff Walden [:Waldo] (remove +bmo to email) 2011-06-17 16:05:07 PDT
Comment on attachment 538142 [details] [diff] [review]
Patch (v1)

>-    return (JSContext *) ((uint8 *) link - offsetof(JSContext, link));
>+    return (JSContext *) (void *) ((uint8 *) link - offsetof(JSContext, link));

Another place where uintptr_t seems better than an extra cast:

>+    return reinterpret_cast<JSContext *>(uintptr_t(link) - offsetof(JSContext, link));
Comment 3 :Ehsan Akhgari 2011-06-20 06:57:37 PDT
http://hg.mozilla.org/tracemonkey/rev/3167cf2cde1c
Comment 4 Chris Leary [:cdleary] (not checking bugmail) 2011-06-20 17:06:30 PDT
cdleary-bot mozilla-central merge info:
http://hg.mozilla.org/mozilla-central/rev/3167cf2cde1c

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