Last Comment Bug 662969 - Silence the clang warnings issued because of alignment requirements increase when compiling jsparse.h
: Silence the clang warnings issued because of alignment requirements increase ...
Product: Core
Classification: Components
Component: JavaScript Engine (show other bugs)
: unspecified
: x86 Mac OS X
-- normal (vote)
: mozilla7
Assigned To: :Ehsan Akhgari
: Jason Orendorff [:jorendorff]
Depends on:
  Show dependency treegraph
Reported: 2011-06-08 16:23 PDT by :Ehsan Akhgari
Modified: 2011-06-20 17:06 PDT (History)
1 user (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

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

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

In file included from /Users/ehsanakhgari/moz/tmp/js/src/jsatom.cpp:58:
/Users/ehsanakhgari/moz/tmp/js/src/jsparse.h:654:16: warning: cast from 'char *' to 'JSParseNode *' increases required alignment from 1 to 8 [-Wcast-align]
        return (JSParseNode *)((char *)pn_tail - offsetof(JSParseNode, pn_next));
Comment 1 User image :Ehsan Akhgari 2011-06-08 16:24:41 PDT
Created attachment 538143 [details] [diff] [review]
Patch (v1)
Comment 2 User image Jeff Walden [:Waldo] (remove +bmo to email) 2011-06-17 16:07:16 PDT
Comment on attachment 538143 [details] [diff] [review]
Patch (v1)

>-        return (JSParseNode *)((char *)pn_tail - offsetof(JSParseNode, pn_next));
>+        return (JSParseNode *)(void *)((char *)pn_tail - offsetof(JSParseNode, pn_next));

More uintptr_t:

>+        return (JSParseNode *)(uintptr_t(pn_tail) - offsetof(JSParseNode, pn_next));

(reinterpret_cast<> butts up against the JS line length limit in this case, hence why I wouldn't use it.)
Comment 3 User image :Ehsan Akhgari 2011-06-20 06:58:05 PDT
Comment 4 User image Chris Leary [:cdleary] (not checking bugmail) 2011-06-20 17:06:37 PDT
cdleary-bot mozilla-central merge info:

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