September 13, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8651

           Summary: Slice op Slice throws exceptions (not errors), and
                    nothrow
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: monarchdodra@gmail.com


--- Comment #0 from monarchdodra@gmail.com 2012-09-13 08:42:59 PDT ---
2 related problems:

First
--------
import std.stdio;
void main()
{
  try
  {
    int[] b = new int[](10);
    b[] = 5;
    b[0..6] = b[4..10];
  }
  catch(Exception e)
  {
    writeln(e);
  }
  writeln("finish");
}
--------
The built-in range assign will throw an Exception when it fails. This should be an Error.

Second
--------
nothrow void foo(int[] a)
{
  a[] = a[];
}

nothrow void bar(int[] a)
{
  a[] += a[];
}
--------
_arraySliceSliceAddass_i is not nothrow
function main.bar 'bar' is nothrow yet may throw
--------
This is doubly problematic:
First, these methods should throw Errors, so the code should compile.
Two, ironically, []+=[] currently doesn't throw anything, and []=[] throws an
exception, yet it is the []+=[] version that doesn't compile.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 16, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8651



--- Comment #1 from monarchdodra@gmail.com 2012-09-15 23:53:18 PDT ---
Also, simple SlicoOp operations should be nothrow:

nothrow void foo(int[] a)
{
  a[] += 5;
}
Error: _arrayExpSliceAddass_i is not nothrow
Error: function main.foo 'foo' is nothrow yet may throw


nothrow void foo(int[] a)
{
  a[] &= 5;
}
Error: _arrayExpSliceAddass_i is not nothrow
Error: function main.foo 'foo' is nothrow yet may throw

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 25, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8651



--- Comment #2 from github-bugzilla@puremagic.com 2012-09-25 16:34:27 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/druntime

https://github.com/D-Programming-Language/druntime/commit/92f92aa87c30370a2c7641499977dd0e53982540 @trusted nothrow issue 8651 #8651

https://github.com/D-Programming-Language/druntime/commit/92f92aa87c30370a2c7641499977dd0e53982540 @trusted nothrow issue 8651 #8651

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 25, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8651


bearophile_hugs@eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs@eml.cc


--- Comment #3 from bearophile_hugs@eml.cc 2012-09-25 16:43:44 PDT ---
And someday even [1,2].dup will be nothrow.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 26, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8651



--- Comment #4 from monarchdodra@gmail.com 2012-09-25 23:26:30 PDT ---
(In reply to comment #3)
> And someday even [1,2].dup will be nothrow.

Doesn't dup allocate?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 17, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8651



--- Comment #5 from monarchdodra@gmail.com 2012-12-17 00:10:00 PST ---
(In reply to comment #0)
> 2 related problems:
> 
> First
> --------
> import std.stdio;
> void main()
> {
>   try
>   {
>     int[] b = new int[](10);
>     b[] = 5;
>     b[0..6] = b[4..10];
>   }
>   catch(Exception e)
>   {
>     writeln(e);
>   }
>   writeln("finish");
> }
> --------
> The built-in range assign will throw an Exception when it fails. This should be an Error.

Confirmed fixed.

> Second
> --------
> nothrow void foo(int[] a)
> {
>   a[] = a[];
> }
> 
> nothrow void bar(int[] a)
> {
>   a[] += a[];
> }
> --------
> _arraySliceSliceAddass_i is not nothrow
> function main.bar 'bar' is nothrow yet may throw
> --------
> This is doubly problematic:
> First, these methods should throw Errors, so the code should compile.
> Two, ironically, []+=[] currently doesn't throw anything, and []=[] throws an
> exception, yet it is the []+=[] version that doesn't compile.


!!!!!!!!
This is NOT FIXED.
!!!!!!!!

This is very strange, because arraySliceSliceAddass_i *is* marked as nothrow. However, when calling "a[] += a[]", I still get:
----
Error: _arraySliceSliceAddass_l is not nothrow
----

I'm not sure what to make about this? Maybe the "nothrow" info is lost in the "extern C" ?

If I place the code as a unittest *inside* "src/rt/arrayint.d", then it passes. But outside of that source, then... It doesn't compile.

We'd need one of the compiler guys (or just people that understand C and linking better than I do) to investigate.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 02, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=8651


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yebblies@gmail.com


--- Comment #6 from yebblies <yebblies@gmail.com> 2013-01-02 17:09:31 EST ---
(In reply to comment #5)
> 
> !!!!!!!!
> This is NOT FIXED.
> !!!!!!!!
> 
> This is very strange, because arraySliceSliceAddass_i *is* marked as nothrow. However, when calling "a[] += a[]", I still get:
> ----
> Error: _arraySliceSliceAddass_l is not nothrow
> ----
> 
> I'm not sure what to make about this? Maybe the "nothrow" info is lost in the "extern C" ?
> 
> If I place the code as a unittest *inside* "src/rt/arrayint.d", then it passes. But outside of that source, then... It doesn't compile.
> 
> We'd need one of the compiler guys (or just people that understand C and linking better than I do) to investigate.

Being C functions, the nothrowness is not part of the mangled name, otherwise that change would have caused lots of link failures.  Inside the compiler (arrayop.c) a dummy function declaration is created with the correct name, and a call is inserted in place of the array op.

This function declaration needs to be changed for the compiler to pick it up as nothrow, and it will need to be manually verified that the nothrowness matches at both ends for each function.

A lot of druntime functions should probably have D linkage to prevent mistakes like this.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 07, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=8651


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simendsjo@gmail.com


--- Comment #7 from Kenji Hara <k.hara.pg@gmail.com> 2013-06-06 19:10:06 PDT ---
*** Issue 6311 has been marked as a duplicate of this issue. ***

--- Comment #8 from Kenji Hara <k.hara.pg@gmail.com> 2013-06-06 19:10:07 PDT ---
*** Issue 9933 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 07, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=8651


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simendsjo@gmail.com


--- Comment #7 from Kenji Hara <k.hara.pg@gmail.com> 2013-06-06 19:10:06 PDT ---
*** Issue 6311 has been marked as a duplicate of this issue. ***

--- Comment #8 from Kenji Hara <k.hara.pg@gmail.com> 2013-06-06 19:10:07 PDT ---
*** Issue 9933 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 07, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=8651


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
            Version|unspecified                 |D2


--- Comment #9 from Kenji Hara <k.hara.pg@gmail.com> 2013-06-06 20:46:04 PDT ---
A while ago, built-in array-op implementations has been changed to @trusted nothrow by the druntime fix:

https://github.com/D-Programming-Language/druntime/pull/306

But, as yebblies said in comment #6, this still needs compiler fix.

I opened a new pull request for the compiler fix.

https://github.com/D-Programming-Language/dmd/pull/2141


(In reply to comment #6)
> (In reply to comment #5)
> A lot of druntime functions should probably have D linkage to prevent mistakes
> like this.

From 2.063, we can use pragma(mangle). Using it could add D linkages to the druntime functions with hiding internal module packages.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
« First   ‹ Prev
1 2
Top | Discussion index | About this forum | D home