www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8819] New: void static array should have init built-in propert

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8819

           Summary: void static array should have init built-in propert
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: k.hara.pg gmail.com



Following code doesn't work with current dmd (2.060).

void main()
{
  alias void[1] T;
  auto vsa = T.init;
}

output:
test.d(4): Error: void does not have a default initializer

I think this is unnecessary restriction and almost a bug.
An element of void[1] should have '0' as a default initializer.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 14 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8819


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull



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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 24 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8819


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla digitalmars.com



18:07:49 PST ---
I'm not convinced this is a good idea. void[] is supposed to be untyped data,
and a 0 initializer is specific to some types, and not for others.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 03 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8819





 I'm not convinced this is a good idea. void[] is supposed to be untyped data,
 and a 0 initializer is specific to some types, and not for others.
In almost cases, void[] and void[n] are used to represent *bare* memory. Then, 0-initialized bare memory is enough acceptable concept to me. --- The enhancement only I argue is just to add init property. That means, default construction of void[n] should be kept invalid. void main() { void[1] vsa1 = (void[1]).init; // allowed by this enhancement void[1] vsa2; // default construction should still be error } I think void[n] should behave as like a struct has ` disable this();`. All structs have built-in `.init`. Therefore void[n] should also have `.init`. --- From a view of meta-programming, I think that all types which has run-time representation should have .init property. It is consistent and much useful. Example: template isSomeCheck(T) { enum isSomeCheck = is(typeof({ T t = T.init; // Can ignore T's constructing way. func(t); // check whether func accepts an lvalue object typed T func(T.init); // check whether func accepts an rvalue object typed T } } After taking this enhancement, only one type which doesn't have init property is void. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 03 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8819




In discussion here:
https://github.com/D-Programming-Language/phobos/pull/842#issuecomment-9420485

Andrei asks why `defaultInit` is necessary, the answer is the lack of
void[1].init.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 04 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8819




Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/a4275e7847f553a3a2c038883612af7b68117ce3
fix Issue 8819 - void static array should have init built-in property

https://github.com/D-Programming-Language/dmd/commit/c437fad3e8bc874ca8f1dcb0e77e8eb6488b5cf1


Issue 8819 - void static array should have init built-in property

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 06 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8819


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


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