www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2348] New: T.init == void ==> T[1] rejected

reply d-bugmail puremagic.com writes:

           Summary: T.init == void   ==> T[1] rejected
           Product: D
           Version: 1.035
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: svv1999 hotmail.com

void main(){
  typedef ubyte B=void;
  B[1] b; // Error: void initializer has no value

The initializing procedure for static arrays should be smart enough to not try
to initialize the elements, whenever for the underlying type T `.init' is

For dynamic arrays the initializer, changed by the same typedef, seems to be

Sep 08 2008
parent d-bugmail puremagic.com writes:

svv1999 hotmail.com changed:

           What    |Removed                     |Added
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID

------- Comment #1 from svv1999 hotmail.com  2008-09-11 06:49 -------
dmd handles this case correctly, because overloading the meaning of `void' in
`T= void' with "do not initialize `T'" seems wrong.

An initializer of `T= void' should have the semantics, that declaring a
variable `v' of type `T' without initializer is rejected, as it is exposed in
the example given.

   typedef ubyte B=void;
   B[1] b=0;  // works as expected 

Sep 11 2008