Issue 13607 - BigInt math not usable in @safe code
Summary: BigInt math not usable in @safe code
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P4 enhancement
Assignee: No Owner
URL:
Keywords: pull, safe
Depends on:
Blocks: 18110
  Show dependency treegraph
 
Reported: 2014-10-13 02:59 UTC by Brad Roberts
Modified: 2024-12-01 16:22 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Brad Roberts 2014-10-13 02:59:11 UTC
module bitintsafe;

import std.bigint;

void main() @safe
{
    BigInt i, j, k;
    i = j + k;
}

$ dmd -c bigintsafe.d
bigintsafe.d(8): Error: safe function 'D main' cannot call system function 'std.bigint.BigInt.opBinary!("+", BigInt).opBinary'

I started looking into this but the rabit hole is fairly deep.  Filing a bug in hopes that someone will take up the charge on this one while I work on others.  I don't consider this an enhancement request since @safe and phobos really need to be in the 'just works' state.
Comment 1 Robert Schadek 2014-10-14 12:19:27 UTC
I had a PR open for this a while back.

https://github.com/D-Programming-Language/phobos/pull/2357

It came down to the same argument you're having on the newsgroup right now.
Comment 2 Brad Roberts 2014-10-14 17:05:01 UTC
It also suffered from being too big.  It would have been nice to get the non-controversial parts of the change in.  There was very little use of the @trusted sledge hammer.
Comment 3 Robert Schadek 2014-10-14 20:43:31 UTC
https://github.com/D-Programming-Language/phobos/pull/2612

another try
Comment 4 Walter Bright 2016-06-12 08:13:17 UTC
(In reply to Robert Schadek from comment #3)
> https://github.com/D-Programming-Language/phobos/pull/2612
> 
> another try

That was merged, but the error remains.
Comment 5 hsteoh 2017-04-26 18:03:22 UTC
A further step in this direction:

https://github.com/dlang/phobos/pull/5354

It's still not complete; BigInt is a pretty deep rabbit warren that will need some time to completely sort out. One step at a time!
Comment 6 hsteoh 2017-04-26 18:45:08 UTC
What should be done about the inline asm heavily used by the BigInt implementation?  We could use the sledgehammer approach and slap @trusted on all the inline asm code, but I'm a bit hesitant to do that.
Comment 7 berni44 2019-12-24 12:48:11 UTC
This is more an enhancement, than a bug. Isn't it?
Comment 8 dlangBugzillaToGithub 2024-12-01 16:22:41 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/phobos/issues/10092

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB