Thread overview
Is DMD breaking BigInt?
Apr 07, 2017
Russel Winder
Apr 07, 2017
Jack Stouffer
Apr 08, 2017
Russel Winder
Apr 08, 2017
ag0aep6g
Apr 07, 2017
David Nadlinger
Apr 08, 2017
Russel Winder
Apr 08, 2017
Johan Engelen
Apr 07, 2017
Meta
Apr 08, 2017
Russel Winder
Apr 08, 2017
Meta
April 07, 2017
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.

-- 
Russel. ============================================================================= Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder@ekiga.net 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

April 07, 2017
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?
April 07, 2017
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
April 07, 2017
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?
April 08, 2017
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?

-- 
Russel. ============================================================================= Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder@ekiga.net 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

April 08, 2017
On Fri, 2017-04-07 at 20:38 +0000, David Nadlinger via Digitalmars-d- learn wrote:
> […]
> 
> You might want to check with LDC from Git master first to see whether it is in fact a 2.073-related problem. — 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?

-- 
Russel. ============================================================================= Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder@ekiga.net 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

April 08, 2017
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 testing. Works fine with ldc2 breaks with dmd.
> 
> 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


-- 
Russel. ============================================================================= Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder@ekiga.net 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

April 08, 2017
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

April 08, 2017
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
April 08, 2017
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.