Make mozilla::detail::ComputeGrowth inline instead of static to fix -Wunused-template with clang 23
Categories
(Core :: MFBT, defect)
Tracking
()
People
(Reporter: Sylvestre, Assigned: Sylvestre)
References
(Blocks 2 open bugs, Regression)
Details
(Keywords: regression)
Attachments
(1 external file)
Building with clang 23 fails in any TU that includes mfbt/Vector.h:
In file included from obj-x86_64-pc-linux-gnu/memory/replace/dmd/Unified_cpp_memory_replace_dmd0.cpp:2:
In file included from memory/replace/dmd/DMD.cpp:38:
In file included from mfbt/JSONWriter.h:100:
mfbt/Vector.h:131:15: error: unused function template 'ComputeGrowth' [-Werror,-Wunused-template]
131 | static size_t ComputeGrowth(
| ^~~~~~~~~~~~~
mozilla::detail::ComputeGrowth is a SFINAE overload pair: one version forwards
to the AllocPolicy's own computeGrowth<EltSize>() when it has one, the other
falls back to GrowEltsByDoubling(). Any given translation unit selects exactly
one of the two, so the other is necessarily unused. Because both are declared
static, that unused one is an internal-linkage template with no
instantiations, which is precisely what -Wunused-template reports.
The fix is to declare them inline rather than static, matching
GrowEltsByDoubling() directly above them:
-static size_t ComputeGrowth(size_t aOldElts, size_t aIncr, int) {
+inline size_t ComputeGrowth(size_t aOldElts, size_t aIncr, int) {
-static size_t ComputeGrowth(
+inline size_t ComputeGrowth(
-Wunused-template only applies to internal-linkage templates, so this removes
the warning at its source instead of suppressing it. The definitions are
identical in every translation unit, so external linkage raises no ODR concern,
and the only caller is Vector.h:1094 within mozilla::detail
| Assignee | ||
Updated•3 months ago
|
| Assignee | ||
Comment 1•3 months ago
|
||
Updated•3 months ago
|
Updated•3 months ago
|
Comment 4•3 months ago
|
||
Set release status flags based on info from the regressing bug 1774733
Updated•3 months ago
|
Updated•2 months ago
|
Description
•