http://d.puremagic.com/issues/show_bug.cgi?id=11188
Summary: std.math.abs fails for shared, const or immutable
BigInt types
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: Phobos
AssignedTo: [email protected]
ReportedBy: [email protected]
--- Comment #0 from Joseph Rushton Wakeling <[email protected]>
2013-10-07 05:27:33 PDT ---
Created an attachment (id=1259)
Example code illustrating the problem with std.math.abs and shared, const or
immutable BigInts.
std.math.abs seems to work effectively with all mutable numeric types,
including std.bigint.BigInt.
However, if BigInts are qualified as shared, const or immutable, std.math.abs
will fail to compile.
Sample code attached illustrating the problem. rdmd bigabs.d gives the errors:
------------------------------------------------------------------------------
bigabs.d(6): Error: template std.math.abs does not match any function template
declaration. Candidates are:
/opt/dmd/include/d2/std/math.d(303): std.math.abs(Num)(Num x) if
(is(typeof(Num.init >= 0)) && is(typeof(-Num.init)) && !(is(Num* :
const(ifloat*)) || is(Num* : const(idouble*)) || is(Num* : const(ireal*))))
/opt/dmd/include/d2/std/math.d(314): std.math.abs(Num)(Num z) if
(is(Num* : const(cfloat*)) || is(Num* : const(cdouble*)) || is(Num* :
const(creal*)))
/opt/dmd/include/d2/std/math.d(322): std.math.abs(Num)(Num y) if
(is(Num* : const(ifloat*)) || is(Num* : const(idouble*)) || is(Num* :
const(ireal*)))
bigabs.d(6): Error: template std.math.abs(Num)(Num x) if (is(typeof(Num.init >=
0)) && is(typeof(-Num.init)) && !(is(Num* : const(ifloat*)) || is(Num* :
const(idouble*)) || is(Num* : const(ireal*)))) cannot deduce template function
from argument types !()(shared(BigInt))
bigabs.d(14): Error: template instance bigabs.foo!(shared(BigInt)) error
instantiating
bigabs.d(6): Error: template std.math.abs does not match any function template
declaration. Candidates are:
/opt/dmd/include/d2/std/math.d(303): std.math.abs(Num)(Num x) if
(is(typeof(Num.init >= 0)) && is(typeof(-Num.init)) && !(is(Num* :
const(ifloat*)) || is(Num* : const(idouble*)) || is(Num* : const(ireal*))))
/opt/dmd/include/d2/std/math.d(314): std.math.abs(Num)(Num z) if
(is(Num* : const(cfloat*)) || is(Num* : const(cdouble*)) || is(Num* :
const(creal*)))
/opt/dmd/include/d2/std/math.d(322): std.math.abs(Num)(Num y) if
(is(Num* : const(ifloat*)) || is(Num* : const(idouble*)) || is(Num* :
const(ireal*)))
bigabs.d(6): Error: template std.math.abs(Num)(Num x) if (is(typeof(Num.init >=
0)) && is(typeof(-Num.init)) && !(is(Num* : const(ifloat*)) || is(Num* :
const(idouble*)) || is(Num* : const(ireal*)))) cannot deduce template function
from argument types !()(const(BigInt))
bigabs.d(15): Error: template instance bigabs.foo!(const(BigInt)) error
instantiating
bigabs.d(6): Error: template std.math.abs does not match any function template
declaration. Candidates are:
/opt/dmd/include/d2/std/math.d(303): std.math.abs(Num)(Num x) if
(is(typeof(Num.init >= 0)) && is(typeof(-Num.init)) && !(is(Num* :
const(ifloat*)) || is(Num* : const(idouble*)) || is(Num* : const(ireal*))))
/opt/dmd/include/d2/std/math.d(314): std.math.abs(Num)(Num z) if
(is(Num* : const(cfloat*)) || is(Num* : const(cdouble*)) || is(Num* :
const(creal*)))
/opt/dmd/include/d2/std/math.d(322): std.math.abs(Num)(Num y) if
(is(Num* : const(ifloat*)) || is(Num* : const(idouble*)) || is(Num* :
const(ireal*)))
bigabs.d(6): Error: template std.math.abs(Num)(Num x) if (is(typeof(Num.init >=
0)) && is(typeof(-Num.init)) && !(is(Num* : const(ifloat*)) || is(Num* :
const(idouble*)) || is(Num* : const(ireal*)))) cannot deduce template function
from argument types !()(immutable(BigInt))
bigabs.d(16): Error: template instance bigabs.foo!(immutable(BigInt)) error
instantiating
Failed: 'dmd' '-v' '-o-' 'bigabs.d' '-I.'
------------------------------------------------------------------------------
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------