GDC binary for windows?

2022-12-15 Thread TheZipCreator via Digitalmars-d-learn
is there a compiled binary of GDC anywhere? I looked at 
https://www.gdcproject.org/downloads, and the link there goes to 
winlibs, but after downloading the archive I couldn't find gdc 
anywhere in it. I did some research and [it appears they removed 
it](https://forum.dlang.org/thread/rcfevunwsgydorekw...@forum.dlang.org?page=2) for whatever reason. In the release archives there are some windows GDC binaries but those are all old versions and they lack the compiler flags I need (specifically `-fno-druntime`). So, are there binaries that still exist somewhere or do I just have to try to compile it from source?


Re: Unique!struct bug - Re: unique_ptr | Unique for autoclose handle

2022-12-15 Thread Ali Çehreli via Digitalmars-d-learn

On 12/15/22 11:31, Nick Treleaven wrote:
> On Wednesday, 14 December 2022 at 17:41:07 UTC, Ali Çehreli wrote:
>> I've never used Unique but I think it has a bug (or a design issue?):
>> Its destructor is the following:
>>
>> ~this()
>> {
>> if (_p !is null)
>> {
>> destroy(_p);
>> _p = null;
>> }
>> }
>>
>> Because _p is a pointer, destroy(_p) will not dereference and destroy
>> what it points to. I think this is a bug with Unique. I think it
>> should do
>>
>>   destroy(*_p);
>
> Now filed:
> https://issues.dlang.org/show_bug.cgi?id=23561

Thanks. I was hoping others more experienced with Phobos implementation 
chime in. But to me, the intention is to destroy the object. One never 
wants to destroy a pointer as there is no operation there.


As a minor proud moment, I do cover this issue:

  http://ddili.org/ders/d.en/memory.html#ix_memory.destroy

> Do you think it's OK to just fix this or

I think this is a bug because the documentation clearly talks about 
destroying the object:


  https://dlang.org/library/std/typecons/unique.html

"When a Unique!T goes out of scope it will call destroy on the
resource T that it manages, unless it is transferred. One
important consequence of destroy is that it will call the
destructor of the resource T."

>  do we need to do some kind of deprecation?

The behavior is so different from the intention that I don't think 
anybody is using Unique anyway. :o)


Ali



Re: pointer escaping return scope bug?

2022-12-15 Thread Nick Treleaven via Digitalmars-d-learn
On Thursday, 15 December 2022 at 20:02:38 UTC, Nick Treleaven 
wrote:

auto f() return @trusted => p ? p : v.ptr;


Whoops, that can't be @trusted unless I `assert(p)`.


Re: pointer escaping return scope bug?

2022-12-15 Thread Nick Treleaven via Digitalmars-d-learn

On Saturday, 19 November 2022 at 15:24:33 UTC, Dukc wrote:
On Saturday, 19 November 2022 at 15:02:54 UTC, Nick Treleaven 
wrote:

OK, so how do I make `lf` implicitly scope?


Have the `int*` inside it to point to a local, or assign 
another `scope int*` to it.


Thanks, this works:

```d
@safe:

struct S
{
int* p;
int[0] v; // dummy storage
auto f() return @trusted => p ? p : v.ptr;
}

void main()
{
int* p;
{
S s = S(new int);
p = s.f; // error
}
}
```


Unique!struct bug - Re: unique_ptr | Unique for autoclose handle

2022-12-15 Thread Nick Treleaven via Digitalmars-d-learn

On Wednesday, 14 December 2022 at 17:41:07 UTC, Ali Çehreli wrote:
I've never used Unique but I think it has a bug (or a design 
issue?): Its destructor is the following:


~this()
{
if (_p !is null)
{
destroy(_p);
_p = null;
}
}

Because _p is a pointer, destroy(_p) will not dereference and 
destroy what it points to. I think this is a bug with Unique. I 
think it should do


  destroy(*_p);


Now filed:
https://issues.dlang.org/show_bug.cgi?id=23561

Do you think it's OK to just fix this or do we need to do some 
kind of deprecation?