On Saturday, 18 April 2020 at 08:39:52 UTC, tsbockman wrote:

[...]

You also get a deprecation message, about an integral promotion not being performed. I believe the result is correct and the warning can be ignored.

So the warning is a bug?

The deprecation message is a consequence of a (very annoying) language change made after std.experimental.checkedint was written. It's not really a bug, although someone should probably fix it anyway.

The message suggests using -preview=intpromote. But it produces another error:

```minusminus.d
void foo ()
{
   import std.experimental.checkedint;
   Checked!(short) b;
   --b;
}
```

$ dmd -preview=intpromote minusminus.d
[...]/linux/bin64/../../src/phobos/std/experimental/checkedint.d(727): Error: 
cannot implicitly convert expression onOverflow(this.payload) of type int to 
short
minusminus.d(5): Error: template instance std.experimental.checkedint.Checked!(short, Abort).Checked.opUnary!"--" error instantiating

Anyway, you might want to give my checkedint package on DUB a try, instead:

    https://code.dlang.org/packages/checkedint

Hm.

$ dub test
Generating test runner configuration 'checkedint-test-library' for 'library' (library). Excluding package.d file from test due to https://issues.dlang.org/show_bug.cgi?id=11847 Performing "unittest" build using [...]/linux/bin64/dmd for x86_64. checkedint ~master: building configuration "checkedint-test-library"...
Linking...
Running ./checkedint-test-library
source/checkedint/package.d(672): [unittest] unittest failure
core.exception.AssertError@source/checkedint/package.d(672): unittest failure
----------------
??:? _d_unittestp [0x4c07b5]
source/checkedint/package.d:672 void checkedint.__unittest_L654_C5() [0x49959c]
??:? void checkedint.__modtest() [0x4bc4b2]
??:? int core.runtime.runModuleUnitTests().__foreachbody2(object.ModuleInfo*) [0x4da1ec] ??:? int object.ModuleInfo.opApply(scope int delegate(object.ModuleInfo*)).__lambda2(immutable(object.ModuleInfo*)) [0x4bedb7] ??:? int rt.minfo.moduleinfos_apply(scope int delegate(immutable(object.ModuleInfo*))).__foreachbody2(ref rt.sections_elf_shared.DSO) [0x4c581f] ??:? int rt.sections_elf_shared.DSO.opApply(scope int delegate(ref rt.sections_elf_shared.DSO)) [0x4c5d8c] ??:? int rt.minfo.moduleinfos_apply(scope int delegate(immutable(object.ModuleInfo*))) [0x4c57ad] ??:? int object.ModuleInfo.opApply(scope int delegate(object.ModuleInfo*)) [0x4bed89]
??:? runModuleUnitTests [0x4da029]
??:? void rt.dmain2._d_run_main2(char[][], ulong, extern (C) int function(char[][])*).runAll() [0x4c226c] ??:? void rt.dmain2._d_run_main2(char[][], ulong, extern (C) int function(char[][])*).tryExec(scope void delegate()) [0x4c21f8]
??:? _d_run_main2 [0x4c2161]
??:? _d_run_main [0x4c1f1d]
[...]/linux/bin64/../../src/druntime/import/core/internal/entrypoint.d:34 main 
[0x48c241]
??:? __libc_start_main [0x7ffff700e585]
1/3 unittests FAILED
Program exited with code 1


Reply via email to