www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Is DMD breaking BigInt?

reply Russel Winder via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> writes:
Simple Dub build of a Factorial example using Unit-Threaded for
testing. Works fine with ldc2 breaks with dmd. This is on Debian Sid
fully up to date.=C2=A0

|> ldc2 --version
LDC - the LLVM D compiler (1.1.1):
=C2=A0 based on DMD v2.071.2 and LLVM 3.9.1
=C2=A0 built with LDC - the LLVM D compiler (1.1.0)
=C2=A0 Default target: x86_64-pc-linux-gnu
=C2=A0 Host CPU: broadwell
=C2=A0 http://dlang.org - http://wiki.dlang.org/LDC

|> dmd --version
DMD64 D Compiler v2.073.2

|> dub test --compiler=3Dldc2
Package factorial (configuration "unittest") defines no import paths, use {=
"importPaths": [...]} or the default package directory structure to fix thi=
s.
Running custom 'unittest' configuration.
Performing "unittest" build using ldc2 for x86_64.
unit-threaded 0.7.11: target for configuration "library" is up to date.
factorial ~master: building configuration "unittest"...
Running pre-build commands...
Building package unit-threaded in /home/users/russel/.dub/packages/unit-thr=
eaded-0.7.11/unit-threaded/
Performing "$DFLAGS" build using dmd for x86_64.
unit-threaded 0.7.11: building configuration "gen_ut_main"...
Linking...
Running ../../../../.dub/packages/unit-threaded-0.7.11/unit-threaded/gen_ut=
_main -f ut_main.d
To force a rebuild of up-to-date targets, run again with --force.
Running ./factorial-test=20

Automatically generated file ut_main.d
Running unit tests from dirs ["."]
factorial.Check the base case for all algorithms.:
factorial.Check the property for all algorithms.:
factorial.Traditional example-based testing.:

Time taken: 34 ms, 363 =CE=BCs, and 2 hnsecs
3 test(s) run, 0 failed.

OK!

|> dub test
Package factorial (configuration "unittest") defines no import paths, use {=
"importPaths": [...]} or the default package directory structure to fix thi=
s.
Running custom 'unittest' configuration.
Performing "unittest" build using dmd for x86_64.
unit-threaded 0.7.11: target for configuration "library" is up to date.
factorial ~master: building configuration "unittest"...
Running pre-build commands...
Building package unit-threaded in /home/users/russel/.dub/packages/unit-thr=
eaded-0.7.11/unit-threaded/
Performing "$DFLAGS" build using dmd for x86_64.
unit-threaded 0.7.11: building configuration "gen_ut_main"...
Linking...
Running ../../../../.dub/packages/unit-threaded-0.7.11/unit-threaded/gen_ut=
_main -f ut_main.d
factorial.d(71,15): Error: template std.bigint.BigInt.__ctor cannot deduce =
function from argument types !()(string) immutable, candidates are:
/usr/include/dmd/phobos/std/bigint.d(64,5):        std.bigint.BigInt.__ctor=
(Range)(Range s) if (isBidirectionalRange!Range && isSomeChar!(ElementType!=
Range) && !isInfinite!Range)
/usr/include/dmd/phobos/std/bigint.d(146,5):        std.bigint.BigInt.__cto=
r(T)(T x) if (isIntegral!T)
/usr/include/dmd/phobos/std/bigint.d(162,5):        std.bigint.BigInt.__cto=
r(T)(T x) if (is(Unqual!T =3D=3D BigInt))
dmd failed with exit code 1.


If anyone has any useful intelligence as to what happening and how I
can workaround it, I'd be a grateful bunny.
=20
--=20
Russel.
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder ekiga.n=
et
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder
Apr 07 2017
next sibling parent reply Jack Stouffer <jack jackstouffer.com> writes:
On Friday, 7 April 2017 at 17:06:31 UTC, Russel Winder wrote:
 Simple Dub build of a Factorial example using Unit-Threaded for 
 testing. Works fine with ldc2 breaks with dmd.
Can you post the code your using?
Apr 07 2017
parent reply Russel Winder via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> writes:
On Fri, 2017-04-07 at 20:29 +0000, Jack Stouffer via Digitalmars-d-
learn wrote:
 On Friday, 7 April 2017 at 17:06:31 UTC, Russel Winder wrote:
 Simple Dub build of a Factorial example using Unit-Threaded for=C2=A0
 testing. Works fine with ldc2 breaks with dmd.
=20 Can you post the code your using?
I thought I had given a URL to the code on GitHub, maybe not, so here it is: https://github.com/russel/Factorial/tree/master/D --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Apr 08 2017
parent ag0aep6g <anonymous example.com> writes:
On 04/07/2017 07:06 PM, Russel Winder via Digitalmars-d-learn wrote:
 factorial.d(71,15): Error: template std.bigint.BigInt.__ctor cannot deduce
function from argument types !()(string) immutable
On 04/08/2017 02:18 PM, Russel Winder via Digitalmars-d-learn wrote:
 https://github.com/russel/Factorial/tree/master/D
So, factorial.d:71 is this: ---- tuple(30, immutable BigInt("265252859812191058636308480000000")), ---- And the BigInt constructor you're trying to use there is this one [1]: ---- this(Range)(Range s) if ( isBidirectionalRange!Range && isSomeChar!(ElementType!Range) && !isInfinite!Range) ---- In order to construct an immutable object, the constructor must either have the `immutable` attribute, or it must be `pure` so that the object is known to be unique. The constructor being templated, I think `pure` should be inferred when possible. But when I add it explicitly, your code compiles, so the attribute is apparently not inferred. Looks like a compiler bug to me. I've filed an issue: https://issues.dlang.org/show_bug.cgi?id=17309 It works with LDC because their BigInt doesn't have the templated constructor (yet, I guess). [1] https://github.com/dlang/phobos/blob/df82dea9caf4a01f00734001fae62cee38ee4f4e/std/bigint.d#L64-L67
Apr 08 2017
prev sibling next sibling parent reply David Nadlinger <code klickverbot.at> writes:
On Friday, 7 April 2017 at 17:06:31 UTC, Russel Winder wrote:
 If anyone has any useful intelligence as to what happening and 
 how I
 can workaround it, I'd be a grateful bunny.
You might want to check with LDC from Git master first to see whether it is in fact a 2.073-related problem. — David
Apr 07 2017
parent reply Russel Winder via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> writes:
On Fri, 2017-04-07 at 20:38 +0000, David Nadlinger via Digitalmars-d-
learn wrote:
 [=E2=80=A6]
=20
 You might want to check with LDC from Git master first to see=C2=A0
 whether it is in fact a 2.073-related problem. =E2=80=94 David
Rats, I thought I'd got away from manually building LDC. Fedora Rawhide is now on LLVM 4.0 is that going to be a problem building LDC? --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Apr 08 2017
parent Johan Engelen <j j.nl> writes:
On Saturday, 8 April 2017 at 12:16:10 UTC, Russel Winder wrote:
 Fedora Rawhide is now on LLVM 4.0 is that going to be a problem 
 building LDC?
Of course not! ;-) -Johan
Apr 08 2017
prev sibling parent reply Meta <jared771 gmail.com> writes:
On Friday, 7 April 2017 at 17:06:31 UTC, Russel Winder wrote:
 Simple Dub build of a Factorial example using Unit-Threaded for 
 testing. Works fine with ldc2 breaks with dmd. This is on 
 Debian Sid fully up to date.

 |> ldc2 --version
 LDC - the LLVM D compiler (1.1.1):
   based on DMD v2.071.2 and LLVM 3.9.1
   built with LDC - the LLVM D compiler (1.1.0)
   Default target: x86_64-pc-linux-gnu
   Host CPU: broadwell
   http://dlang.org - http://wiki.dlang.org/LDC

 |> dmd --version
 DMD64 D Compiler v2.073.2

 |> dub test --compiler=ldc2
 Package factorial (configuration "unittest") defines no import 
 paths, use {"importPaths": [...]} or the default package 
 directory structure to fix this.
 Running custom 'unittest' configuration.
 Performing "unittest" build using ldc2 for x86_64.
 unit-threaded 0.7.11: target for configuration "library" is up 
 to date.
 factorial ~master: building configuration "unittest"...
 Running pre-build commands...
 Building package unit-threaded in 
 /home/users/russel/.dub/packages/unit-threaded-0.7.11/unit-threaded/
 Performing "$DFLAGS" build using dmd for x86_64.
 unit-threaded 0.7.11: building configuration "gen_ut_main"...
 Linking...
 Running 
 ../../../../.dub/packages/unit-threaded-0.7.11/unit-threaded/gen_ut_main -f
ut_main.d
 To force a rebuild of up-to-date targets, run again with 
 --force.
 Running ./factorial-test

 Automatically generated file ut_main.d
 Running unit tests from dirs ["."]
 factorial.Check the base case for all algorithms.:
 factorial.Check the property for all algorithms.:
 factorial.Traditional example-based testing.:

 Time taken: 34 ms, 363 μs, and 2 hnsecs
 3 test(s) run, 0 failed.

 OK!

 |> dub test
 Package factorial (configuration "unittest") defines no import 
 paths, use {"importPaths": [...]} or the default package 
 directory structure to fix this.
 Running custom 'unittest' configuration.
 Performing "unittest" build using dmd for x86_64.
 unit-threaded 0.7.11: target for configuration "library" is up 
 to date.
 factorial ~master: building configuration "unittest"...
 Running pre-build commands...
 Building package unit-threaded in 
 /home/users/russel/.dub/packages/unit-threaded-0.7.11/unit-threaded/
 Performing "$DFLAGS" build using dmd for x86_64.
 unit-threaded 0.7.11: building configuration "gen_ut_main"...
 Linking...
 Running 
 ../../../../.dub/packages/unit-threaded-0.7.11/unit-threaded/gen_ut_main -f
ut_main.d
 factorial.d(71,15): Error: template std.bigint.BigInt.__ctor 
 cannot deduce function from argument types !()(string) 
 immutable, candidates are:
 /usr/include/dmd/phobos/std/bigint.d(64,5):        
 std.bigint.BigInt.__ctor(Range)(Range s) if 
 (isBidirectionalRange!Range && isSomeChar!(ElementType!Range) 
 && !isInfinite!Range)
 /usr/include/dmd/phobos/std/bigint.d(146,5):        
 std.bigint.BigInt.__ctor(T)(T x) if (isIntegral!T)
 /usr/include/dmd/phobos/std/bigint.d(162,5):        
 std.bigint.BigInt.__ctor(T)(T x) if (is(Unqual!T == BigInt))
 dmd failed with exit code 1.


 If anyone has any useful intelligence as to what happening and 
 how I
 can workaround it, I'd be a grateful bunny.
Do you have the -dip1000 switch enabled?
Apr 07 2017
parent reply Russel Winder via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> writes:
On Fri, 2017-04-07 at 22:47 +0000, Meta via Digitalmars-d-learn wrote:
 [=E2=80=A6]
=20
 Do you have the -dip1000 switch enabled?
Not as far as I know. Why would I want to do that? --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Apr 08 2017
parent Meta <jared771 gmail.com> writes:
On Saturday, 8 April 2017 at 12:14:31 UTC, Russel Winder wrote:
 On Fri, 2017-04-07 at 22:47 +0000, Meta via Digitalmars-d-learn 
 wrote:
 […]
 
 Do you have the -dip1000 switch enabled?
Not as far as I know. Why would I want to do that?
You wouldn't as the std lib doesn't work with it yet.
Apr 08 2017