Source code

Revision control

Copy as Markdown

Other Tools

From 6a78346cf7e755a9f5a206ca9011694bf073ea12 Mon Sep 17 00:00:00 2001
From: Bob Hood <bhood@mozilla.com>
Date: Mon, 17 Aug 2026 11:58:51 -0600
Subject: [PATCH] Avoid implicit StrictNumeric conversion in a new[] size
expression
CheckedNumeric::ValueOrDie() returns StrictNumeric<Dst>, whose conversion to
Dst is a template with a deduced parameter. GCC cannot deduce it when the value
is used as the size expression of a new[], failing with:
error: default type conversion cannot deduce template argument for
'template<class Dst, ...> constexpr StrictNumeric<T>::operator Dst() const'
Note that spelling out ValueOrDie's own template argument does not help, since
the unconvertible value is its StrictNumeric return type rather than the call
itself. Cast explicitly instead, which gives the conversion operator a concrete
destination type.
Compile-only change; checkedArraySize is already a CheckedNumeric<size_t>.
---
src/compiler/translator/IntermNode.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/compiler/translator/IntermNode.cpp b/src/compiler/translator/IntermNode.cpp
index 710bba9..33d4a64 100644
--- a/src/compiler/translator/IntermNode.cpp
+++ b/src/compiler/translator/IntermNode.cpp
@@ -880,7 +880,7 @@ const TConstantUnion *TIntermAggregate::getConstantValue() const
angle::base::CheckedNumeric<size_t> checkedArraySize = elementSize;
checkedArraySize *= getOutermostArraySize();
- constArray = new TConstantUnion[checkedArraySize.ValueOrDie()];
+ constArray = new TConstantUnion[static_cast<size_t>(checkedArraySize.ValueOrDie())];
size_t elementOffset = 0u;
for (TIntermNode *constructorArg : mArguments)
--
2.43.0