[phobos] Variant broken for large types

Andrei Alexandrescu andrei at erdani.com
Thu Aug 26 23:15:55 PDT 2010


Works fine for me. Did you or someone else fix it in the meantime?

Andrei

On 6/18/10 21:51 PDT, Sean Kelly wrote:
> Variant hurts my brain.  Something's screwy with using large values (ones that dynamic storage is allocated for automatically) but I haven't figured out what yet.  Help?
>
>
>      import std.variant;
>      import std.typecons;
>      import std.stdio;
>
>      void main()
>      {
>          struct Large
>          {
>              int[1024] x;
>          }
>          Large large;
>          Variant v = large;
>          if( v.convertsTo!(Large) )
>              writeln( "yay" );
>      }
>
> (gdb) run
> Starting program: /Users/sean/Projects/3p/test/vtest
> Reading symbols for shared libraries +. done
>
> Program received signal EXC_BAD_ACCESS, Could not access memory.
> Reason: KERN_PROTECTION_FAILURE at address: 0x00000000
> 0x00002754 in D3std7variant17__T8VariantNVk32Z8VariantN24__T7handlerTSmain5LargeZ7handlerFE3std7variant17__T8VariantNVk32Z8VariantN4OpIDPG32hPvZi6getPtrFPvZPSmain5Large ()
> (gdb) bt
> #0  0x00002754 in D3std7variant17__T8VariantNVk32Z8VariantN24__T7handlerTSmain5LargeZ7handlerFE3std7variant17__T8VariantNVk32Z8VariantN4OpIDPG32hPvZi6getPtrFPvZPSmain5Large ()
> #1  0x000023c5 in D3std7variant17__T8VariantNVk32Z8VariantN24__T7handlerTSmain5LargeZ7handlerFE3std7variant17__T8VariantNVk32Z8VariantN4OpIDPG32hPvZi ()
> #2  0x000032e8 in D3std7variant17__T8VariantNVk32Z8VariantN28__T10convertsToTSmain5LargeZ10convertsToMFZb ()
> #3  0x000022a1 in _Dmain ()
> #4  0x0000e92f in D2rt6dmain24mainUiPPaZi7runMainMFZv ()
> #5  0x0000e866 in D2rt6dmain24mainUiPPaZi7tryExecMFMDFZvZv ()
> #6  0x0000e972 in D2rt6dmain24mainUiPPaZi6runAllMFZv ()
> #7  0x0000e866 in D2rt6dmain24mainUiPPaZi7tryExecMFMDFZvZv ()
> #8  0x0000e7f4 in main ()
> (gdb)
>
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos


More information about the phobos mailing list