To answer my own question, I wrote some tests:
https://github.com/compilets/compilets/commit/d69722fb36260caa278843311cb043f5fe8a90d7

It seems that pointers stored in containers can be retained.
(It would be great if someone can verify this though.)

On Thursday, August 8, 2024 at 9:11:33 AM UTC+9 Cheng wrote:

> Cppgc does stack scanning so objects pointed by raw pointers on stack are 
> not garbage collected:
>
> Object* ptr = MakeGarbageCollected<Object>(); // retained.
>
> But what if I put the pointer in a variant?
>
> std::variant<Object*, std::monostate> ptr = 
> MakeGarbageCollected<Object>(); // retain?
>
> Or even in a vector?
>
> std::vector<Object*> ptrs = { MakeGarbageCollected<Object>() }; // retain?
>
> Will the object still be retained by the container of pointer on stack?
>

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/v8-users/9b8d7006-7b5c-41d4-af53-aea05ddf6550n%40googlegroups.com.

Reply via email to