Closed Bug 1073559 Opened 10 years ago Closed 8 years ago

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

Categories

(Core :: MFBT, defect)

33 Branch
x86
Windows Server 2003
defect
Not set
trivial

Tracking

()

RESOLVED DUPLICATE of bug 1287006

People

(Reporter: neil, Unassigned)

Details

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
Closed: 8 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.