C++20 error: static assertion failed due to requirement '!std::is_pointer_v<js::SharedPropMap *>': Pointer type not allowed for StructGCPolicy
Categories
(Core :: JavaScript: GC, defect)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox140 | --- | unaffected |
| firefox141 | --- | wontfix |
| firefox142 | --- | fixed |
People
(Reporter: cpeterson, Assigned: sfink)
References
Details
Attachments
(2 files)
When compiling Firefox with -std=c++20, the build fails with the following static assertion failure in GCPolicyAPI.h. This is a code or compiler regression introduced within the last few months because I successfully compiled Firefox with -std=c++20 (using my patch in bug 1768116) earlier this year.
Bug 1679736 and bug 1459577 are some old fixed bugs related to this std::is_pointer_v assertion.
GCPolicyAPI.h:90:17: error: static assertion failed due to requirement '!std::is_pointer_v<js::SharedPropMap *>': Pointer type not allowed for StructGCPolicy
90 | static_assert(!std::is_pointer_v<T>,
In file included from firefox/js/src/ctypes/Library.cpp:9:
In file included from firefox/js/src/jsapi.h:30:
In file included from firefox/obj-aarch64-apple-darwin24.5.0/dist/include/js/CallAndConstruct.h:15:
In file included from firefox/obj-aarch64-apple-darwin24.5.0/dist/include/js/RootingAPI.h:24:
firefox/obj-aarch64-apple-darwin24.5.0/dist/include/js/GCPolicyAPI.h:90:17: error: static assertion failed due to requirement '!std::is_pointer_v<js::SharedPropMap *>': Pointer type not allowed for StructGCPolicy
90 | static_assert(!std::is_pointer_v<T>,
| ^~~~~~~~~~~~~~~~~~~~~
firefox/obj-aarch64-apple-darwin24.5.0/dist/include/js/GCPolicyAPI.h:108:26: note: in instantiation of template class 'JS::StructGCPolicy<js::SharedPropMap *>' requested here
108 | struct GCPolicy : public StructGCPolicy<T> {};
| ^
firefox/obj-aarch64-apple-darwin24.5.0/dist/include/js/GCVector.h:168:7: note: in instantiation of template class 'JS::GCPolicy<js::SharedPropMap *>' requested here
168 | GCPolicy<T>::trace(trc, &elem, "vector element");
| ^
firefox/obj-aarch64-apple-darwin24.5.0/dist/include/js/GCPolicyAPI.h:93:67: note: in instantiation of member function 'JS::GCVector<js::SharedPropMap *, 8>::trace' requested here
93 | static void trace(JSTracer* trc, T* tp, const char* name) { tp->trace(trc); }
| ^
firefox/obj-aarch64-apple-darwin24.5.0/dist/include/js/RootingAPI.h:971:22: note: in instantiation of member function 'JS::StructGCPolicy<JS::StackGCVector<js::SharedPropMap *>>::trace' requested here
971 | JS::GCPolicy<T>::trace(trc, self->address(), name);
| ^
firefox/obj-aarch64-apple-darwin24.5.0/dist/include/js/RootingAPI.h:967:7: note: in instantiation of member function 'js::TypedRootedTraceableBase<js::StackRootedTraceableBase, JS::StackGCVector<js::SharedPropMap *>>::trace' requested here
967 | class TypedRootedTraceableBase : public Base {
| ^
| Assignee | ||
Comment 1•9 months ago
|
||
Updated•9 months ago
|
| Assignee | ||
Comment 2•9 months ago
|
||
I'm not totally clear on where the instantiation is coming from because clang is truncating the instantiation chain even when I pass -ftemplate-backtrace-limit=0, and gcc doesn't show this error.
But I have a patch that fixes it anyway. The problem is that js::SharedPropMap is an internal type, and the GC policy header only instantiates the pointer policy for public types. Anything else falls back to the struct policy, which produces the error here. So something is instantiating a Rooted<...SharedPropMap*...> without including (directly or indirectly) gc/Policy.h, which changes the default policy for pointers to be the pointer policy.
I just included gc/Policy.h in vm/PropMap.h, which did the trick. (I don't know if it's still possible to get in trouble by forward-declaring SharedPropMap? We probably already require the type to instantiate Rooted stuff, so I think it should be fine.)
| Reporter | ||
Comment 3•9 months ago
|
||
Thanks! I had localized this error to PropMap.h's JS::RootedVector<SharedPropMap*> maps_; declaration from bug 1961324, but I that was as far as I understood.
| Assignee | ||
Comment 4•9 months ago
|
||
(In reply to Chris Peterson [:cpeterson] from comment #3)
Thanks! I had localized this error to PropMap.h's
JS::RootedVector<SharedPropMap*> maps_;declaration from bug 1961324, but I that was as far as I understood.
The errors that come from this are unfortunate. I probably ought to come up with something where it would complain about a line that we could add a comment on, suggesting the likely fix. Maybe instead of defaulting to StructGCPolicy, it could fall back to UnhandledPointerGCPolicyReadTheComment. But I'm not sure how to do that without colliding with InternalGCPointerPolicy.
Oh, wait! I can just expand the static_assert message in StructGCPolicy.
| Assignee | ||
Comment 5•9 months ago
|
||
Comment 7•9 months ago
|
||
| bugherder | ||
Comment 10•8 months ago
|
||
Backed out for causing bugzilla-components failure
Comment 11•8 months ago
|
||
| Assignee | ||
Updated•8 months ago
|
Comment 12•8 months ago
|
||
| bugherder | ||
Description
•