DISALLOW_NEW_EXCEPT_PLACEMENT_NEW is not working as expected |
||
Issue description
When DISALLOW_NEW_EXCEPT_PLACEMENT_NEW is specified, the object should be allowed only on the stack, HeapVector<Object> or HashTable<Object>.
The following case should not be allowed.
class Object { DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); };
class X : public GarbageCollected<X> {
Object obj_;
};
However, it looks like the verification is not working as expected.
For example, MediaTrackCapabilities is put in ImageCapture.
https://cs.chromium.org/chromium/src/third_party/WebKit/Source/modules/imagecapture/ImageCapture.h?q=ImageCapture&sq=package:chromium&dr=CSs&l=5
,
Oct 17 2017
haraken@: Is this dangerous? Do we want to ban this to keep the meaning of the macro strictly "allow only inline allocation"?
,
Oct 17 2017
Yes. For example, we want to prevent people from allocating IDL dictionaries in an on-heap object (because IDL dictionaries may have v8::Local handles). IDL dictionaries should be allowed only on a stack or Vector<> on a stack. > Do we want to ban this to keep the meaning of the macro strictly "allow only inline allocation"? If we don't band it, we won't need DISALLOW_NEW_EXCEPT_PLACEMENT_NEW in the first place...? It should be the same as DISALLOW_NEW.
,
Oct 17 2017
OK I understand now that DISALLOW_NEW_EXCEPT_PLACEMENT_NEW classes should be limited to on stack. Do I need to disallow only-placement-newable fields in stack-allocated classes?
,
Oct 17 2017
Right. STACK_ALLOCATED => Allowed only on a stack. DISALLOW_NEW_EXCEPT_PLACEMENT_NEW => Allowed only on a stack and in Vectors/HashTables.
,
Aug 1
|
||
►
Sign in to add a comment |
||
Comment 1 by haraken@chromium.org
, Oct 6 2017