[Issue 11206] static array can be implicitly built from items, when nested in aggregate

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Oct 9 13:33:43 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=11206



--- Comment #5 from Maxim Fomin <maxim at maxim-fomin.ru> 2013-10-09 13:33:42 PDT ---
Let's start from the basics.

import std.stdio;

struct AGG
{
    int[1] t;
    double d;
}

void main()
{
    AGG tarr2 = AGG(1); 
    writeln(tarr2);
}

Claim is follows: this is a D valid code.

Backing:
1) AGG(1) is a struct literal (struct spec page). Note, that struct literal
really means struct literal, not "default struct constructor" or "implicit
function call" or "call expression" or any other 'creative' understaning of
language rules.
2) Struct literal contains member initializers which should match in order and
type to struct member initializer (struct spec page + TDPL).
3) Integer literal is valid initializer for static array of ints (TDPL).

You can either refute the backing or make contra point that although the code
is valid, it shouldn't be because the code is bad/wrong/unsafe (but I don't see
how you can convince that reasoning is wrong or the code is unsafe).

Before you write again about assignment, call expressions or implicit type
conversion, please note, that whether integeral expression is convertible to
struct, whether integer expression is convertible to static array in call
expression, whether is(int: int[10]) is true, all of this is irrelevant to the
initialization case.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list