Bug 10958 – std.variant : Variant and Algebraic can't use a type when sizeof == 0

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-09-03T14:28:00Z
Last change time
2014-02-15T15:11:44Z
Keywords
pull
Assigned to
opantm2+dbugs
Creator
tcdknutson

Comments

Comment #0 by tcdknutson — 2013-09-03T14:28:05Z
Take, for example, this code: ` import std.variant; void main() { alias FirstType = void[0]; alias SecondType = void[0]; alias Variants = Algebraic!(FirstType, SecondType); } ` Results in the error: $ dmd test_zero_sized_object.d c:\dmd2\windows\bin\..\..\src\phobos\std\variant.d(165): Error: static assert (0u >= 4u) is false c:\dmd2\windows\bin\..\..\src\phobos\std\variant.d(1149): instantiated from here: VariantN!(0u, void[0u], void[0u]) test_zero_sized_object.d(7): instantiated from here: Algebraic!(void[0u], void[0u])
Comment #1 by opantm2+dbugs — 2014-02-13T22:33:10Z
Comment #2 by github-bugzilla — 2014-02-15T14:55:44Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/b21c398ca2aad2934af4eec31dc4cf298d6b0b22 Fix issue 10958 - Variant fails to compile for types with sizeof == 0. https://github.com/D-Programming-Language/phobos/commit/adb9685694c63eae4b42bafa58e21ed69a42b148 Merge pull request #1936 from Kapps/fix10958 Fix issue 10958 - Variant fails to compile for types with sizeof == 0.