Uploaded image for project: 'Swift'
  1. Swift
  2. SR-5267

Optional<Bool> layout is inefficient

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reopened
    • Priority: Medium
    • Resolution: Unresolved
    • Component/s: Compiler
    • Labels:
      None

      Description

      I need to store a bunch of true/false/indeterminate values, but Swift doesn't handle it efficiently:

      (swift) MemoryLayout<(Bool?,Bool?)>.size
      // r0 : Int = 2
      (swift) MemoryLayout<(Bool?,Bool?,Bool?)>.size
      // r1 : Int = 3
      (swift) struct X { var a, b, c: Bool? }
      (swift) MemoryLayout<X>.size
      // r2 : Int = 3
      

      These should all fit in one byte.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              dabrahams Dave Abrahams
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated: