sizeof(Maybe<T>) >= 16 on win32

RESOLVED DUPLICATE of bug 1287006

Status

()

--
trivial
RESOLVED DUPLICATE of bug 1287006
4 years ago
2 years ago

People

(Reporter: neil, Unassigned)

Tracking

33 Branch
x86
Windows Server 2003
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

4 years ago
I was looking at an nsCxPusher which contains a Maybe<nsAutoCxPusher> which itself contains a Maybe<nsJSAutoRequest> and a Maybe<nsJSAutoCompartment>. nsJSAutoRequest just contains a pointer, so its size is 4. But sizeof(Maybe<nsJSAutoRequest>) is 16, so it's 68% empty! The irony is that my nsCxPusher only had 4-byte alignment all along.
We ought to be using something like AlignedElem<sizeof(T)> instead of AlignedStorage2<T>; the only problem is that there exist compilers for which AlignedElem<> won't actually be aligned.  We could make MOZ_ALIGNED_DECL just #error out for those compilers, or we could choose between AlignedElem<> and AlignedStorage2<T> depending on the compiler.
Status: NEW → RESOLVED
Last Resolved: 2 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 1287006
You need to log in before you can comment on or make changes to this bug.