www.digitalmars.com         C & C++   DMDScript  

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

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

           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
`void'.

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


-- 
Sep 08 2008
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2348


svv1999 hotmail.com changed:

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





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