Closed
Bug 687545
Opened 14 years ago
Closed 14 years ago
Raise a runtime warning if nsTArray is allocated on the stack
Categories
(Core :: XPCOM, defect)
Core
XPCOM
Tracking
()
RESOLVED
WONTFIX
People
(Reporter: justin.lebar+bug, Unassigned)
Details
+++ This bug was created as a clone of bug 677571 +++
I'm not sure if we want to do this, because there might be places where nsTArray is legitimately allocated on the stack, but it would have prevented
(From bug 682735 comment 39)
> 8) Hit testing frame list. Short-lived on-stack array. Could be auto-1.
(In reply to Justin Lebar [:jlebar] from comment #0)
> +++ This bug was created as a clone of bug 677571 +++
>
> I'm not sure if we want to do this, because there might be places where
> nsTArray is legitimately allocated on the stack, but it would have prevented
Some possible legitimate reasons:
* array is populated or used with nsTArray<T>::SwapElements (such that the element storage needs to outlive the stack allocation)
* array is usually empty
Also, stack space isn't free; putting large objects on the stack reduces the memory locality of other things on the stack, and increases risks of running out of stack space (especially in certain code).
Before deciding that we want this warning, I think we should look at the warnings it would give and see (by measuring, if possible) if we agree they're things we should fix.
Reporter | ||
Comment 2•14 years ago
|
||
We could make nsAutoTArray<0> not raise a warning. At least then you're explicitly asking for what you're getting.
OTOH, this warning might suggest that one should use nsAutoTArray for stack allocations and nsTArray if the array will live on the heap. I'd like to move away from that mentality...
I agree with dbaron, I don't think we always want this.
Reporter | ||
Updated•14 years ago
|
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → WONTFIX
You need to log in
before you can comment on or make changes to this bug.
Description
•