[Issue 8486] New: Possibly wrong interaction of Variant and const arrays

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jul 31 12:37:02 PDT 2012


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

           Summary: Possibly wrong interaction of Variant and const arrays
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: cybevnm at gmail.com


--- Comment #0 from cybevnm <cybevnm at gmail.com> 2012-07-31 12:36:58 PDT ---
During initializing Variant, D discards top level const of array, which 
leads to little unintuitive behaviour. Consider code:

import std.stdio;
import std.variant;
void main()
{
  const int[] arr;
  Variant v = Variant( arr );
  writeln( v.peek!( typeof( arr ) )() );
  writeln( v.peek!( const(int)[] )() );
  writeln( v.type() );
}

...and output:
%dmd main.d && ./main.d
null
7FFF358AE298
const(int)[]

As you can see peek works successfully not for original array type, but 
for type without top level const. Is Variant supposed to work in that way ?

-- 
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