Thread overview
std.variant holding bigger structs and std.concurrency message limitation
Apr 27, 2013
Tavi Cacina
Apr 27, 2013
Idan Arye
Apr 30, 2013
David Eagen
May 09, 2013
Anonimous
May 09, 2013
David Nadlinger
May 09, 2013
Anonimous
May 09, 2013
David Nadlinger
April 27, 2013
is it a bug the fact that a Variant may be initialized with a struct bigger than 32 bytes? Even if this does function, it is not consistent because you can not assign such an 'inflated' variant to another one, assertion. This affects the max size of a std.concurrency message (right now it is not specified that such restriction exists)

---
import std.variant;

struct S
{
  int[9] s;
}

void main()
{
  Variant v1, v2; // maximum size 32 bytes
  v1 = S(); // works, even if sizeof(S) > 32
  v2 = v1; // AssertError: target must be non-null
}
---
April 27, 2013
On Saturday, 27 April 2013 at 11:37:38 UTC, Tavi Cacina wrote:
> is it a bug the fact that a Variant may be initialized with a struct bigger than 32 bytes? Even if this does function, it is not consistent because you can not assign such an 'inflated' variant to another one, assertion. This affects the max size of a std.concurrency message (right now it is not specified that such restriction exists)
>
> ---
> import std.variant;
>
> struct S
> {
>   int[9] s;
> }
>
> void main()
> {
>   Variant v1, v2; // maximum size 32 bytes
>   v1 = S(); // works, even if sizeof(S) > 32
>   v2 = v1; // AssertError: target must be non-null
> }
> ---

There used to be a maximum size check for placing things in variants, but it was removed back in 2009: https://github.com/D-Programming-Language/phobos/commit/0c142994d9b5cb9f379eca28f3a625c749370e4a#L20L189

The way it works now, is that if the size is too big they use a reference instead: https://github.com/D-Programming-Language/phobos/blob/master/std/variant.d#L544#L555
April 30, 2013
On Saturday, 27 April 2013 at 17:42:54 UTC, Idan Arye wrote:
> The way it works now, is that if the size is too big they use a reference instead: https://github.com/D-Programming-Language/phobos/blob/master/std/variant.d#L544#L555

So is the bug in std.concurrency and they way it uses Variant or is the bug in Variant?

May 09, 2013
On Tuesday, 30 April 2013 at 00:04:04 UTC, David Eagen wrote:
> On Saturday, 27 April 2013 at 17:42:54 UTC, Idan Arye wrote:
>> The way it works now, is that if the size is too big they use a reference instead: https://github.com/D-Programming-Language/phobos/blob/master/std/variant.d#L544#L555
>
> So is the bug in std.concurrency and they way it uses Variant or is the bug in Variant?

Ping.
May 09, 2013
On Tuesday, 30 April 2013 at 00:04:04 UTC, David Eagen wrote:
> On Saturday, 27 April 2013 at 17:42:54 UTC, Idan Arye wrote:
>> The way it works now, is that if the size is too big they use a reference instead: https://github.com/D-Programming-Language/phobos/blob/master/std/variant.d#L544#L555
>
> So is the bug in std.concurrency and they way it uses Variant or is the bug in Variant?

It's a variant bug, please make sure it is on Bugzilla.

David
May 09, 2013
On Thursday, 9 May 2013 at 12:36:36 UTC, David Nadlinger wrote:
> On Tuesday, 30 April 2013 at 00:04:04 UTC, David Eagen wrote:
>> On Saturday, 27 April 2013 at 17:42:54 UTC, Idan Arye wrote:
>>> The way it works now, is that if the size is too big they use a reference instead: https://github.com/D-Programming-Language/phobos/blob/master/std/variant.d#L544#L555
>>
>> So is the bug in std.concurrency and they way it uses Variant or is the bug in Variant?
>
> It's a variant bug, please make sure it is on Bugzilla.
>
> David

Yes, it is reported by Tavi Cacina
http://d.puremagic.com/issues/show_bug.cgi?id=10017

Sorry,I ment that it's an important bug,but maybe everybody was busy
with dconf and just didn't do anything with it.

There is already pull,could you tell about its status?
May 09, 2013
On Thursday, 9 May 2013 at 12:42:25 UTC, Anonimous wrote:
> Sorry,I ment that it's an important bug,but maybe everybody was busy
> with dconf and just didn't do anything with it.

Yep, things are only slowly getting back to normality as jet lag wears off and the recordings are taken care of… ;)

> There is already pull,could you tell about its status?

See my comment there.

David