Closed Bug 659546 Opened 14 years ago Closed 14 years ago

clang warns about alignment requirement increase in nsID::Equals after bug 164580

Categories

(Core :: XPCOM, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla7

People

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

References

Details

Attachments

(1 file)

../../../../dist/include/nsID.h:77:8: warning: cast from 'const PRUint32 *' (aka 'const unsigned int *') to 'PRUint64 *' (aka 'unsigned long long *') increases required alignment from 4 to 8 [-Wcast-align] ((PRUint64*) &m0)[0] == ((PRUint64*) &other.m0)[0] && ^~~~~~~~~~~~~~~ ../../../../dist/include/nsID.h:77:32: warning: cast from 'const PRUint32 *' (aka 'const unsigned int *') to 'PRUint64 *' (aka 'unsigned long long *') increases required alignment from 4 to 8 [-Wcast-align] ((PRUint64*) &m0)[0] == ((PRUint64*) &other.m0)[0] && ^~~~~~~~~~~~~~~~~~~~~ ../../../../dist/include/nsID.h:78:8: warning: cast from 'const PRUint32 *' (aka 'const unsigned int *') to 'PRUint64 *' (aka 'unsigned long long *') increases required alignment from 4 to 8 [-Wcast-align] ((PRUint64*) &m0)[1] == ((PRUint64*) &other.m0)[1]; ^~~~~~~~~~~~~~~ ../../../../dist/include/nsID.h:78:32: warning: cast from 'const PRUint32 *' (aka 'const unsigned int *') to 'PRUint64 *' (aka 'unsigned long long *') increases required alignment from 4 to 8 [-Wcast-align] ((PRUint64*) &m0)[1] == ((PRUint64*) &other.m0)[1]; ^~~~~~~~~~~~~~~~~~~~~ We're basically relying on the correct knowledge of alignment requirements here, so we'd better silence the compiler.
Attached patch Patch (v1)Splinter Review
Assignee: nobody → ehsan
Status: NEW → ASSIGNED
Attachment #534972 - Flags: review?(benjamin)
Wow, those are really pretty compile errors. I like the aka's on the typedefs. Man.
(In reply to comment #2) > Wow, those are really pretty compile errors. I like the aka's on the > typedefs. Man. Reason #73 why clang is eventually going to kill off gcc.
Do we know that nsID is actually 64-bit aligned? Given that none of the members require 64-bit alignment, I'm not sure that the struct is actually always going to be 64-bit aligned.
It would probably be worth forcing 64-bit alignment, if only to be safe. Do we have any macros wrapping the compiler directives for this? I can't seem to find them.
One possible way to force 64-bit alignment that I know of is to wrap its members into two unions, each with a 64-bit member. But that would break the POD-ness of the type... :(
See bug 660335 for forcing alignment of nsID.
Attachment #534972 - Flags: review?(benjamin) → review+
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla7
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: