When both operands of a std.internal.math.biguintcore.BigUint multiplication exceed a certain threshold (the threshold appears to be 1 << 32) during CTFE, the multiplication will fail as std.internal.math.biguintcore.mulInternal attempts to use core.cpuid.dataCaches to optimise algorithm selection.
This happens only if the operands differ, as squaring follows a different code-path.
Test case:
import std.internal.math.biguintcore : BigUint;
enum largeMultiplication = BigUint.mul(BigUint(ulong(1)) << ulong(33), BigUint(ulong(1)) << ulong(32));
resulting in:
import\core\cpuid.d(124): Error: static variable `_dataCaches` cannot be read at compile time
const(CacheInfo)[5] dataCaches() { return _dataCaches; }
^
import\std\internal\math\biguintcore.d(239): called from here: `dataCaches()`
return dataCaches[0].size * 1024 / 2;
^
import\std\internal\math\biguintcore.d(1715): called from here: `getCacheLimit()`
immutable CACHELIMIT = getCacheLimit;
^
import\std\internal\math\biguintcore.d(915): called from here: `mulInternal(result, cast(const(uint)[])x.data, cast(const(uint)[])y.data)`
else mulInternal(result, x.data, y.data);
^
example.d(2): called from here: `mul(BigUint([0u]).this(1LU).opBinary(33LU), BigUint([0u]).this(1LU).opBinary(32LU))`
enum largeMultiplication = BigUint.mul(BigUint(ulong(1)) << ulong(33), BigUint(ulong(1)) << ulong(32));
When both operands of a
std.internal.math.biguintcore.BigUintmultiplication exceed a certain threshold (the threshold appears to be1 << 32) during CTFE, the multiplication will fail asstd.internal.math.biguintcore.mulInternalattempts to usecore.cpuid.dataCachesto optimise algorithm selection.This happens only if the operands differ, as squaring follows a different code-path.
Test case:
resulting in: