2 Replies
      Latest reply on Dec 10, 2019 10:41 AM by dhoerl
      dhoerl Level 1 Level 1 (0 points)

        Experimenting with @autoclosure with variatic parameters. With that qualifier there, compiler faults. Comment just "@autoclosure" out, then it compiles just fine. Code:

         

        fileprivate func LOG(_ flag: Int, _ items: @autoclosure Any..., separator: String = " ", terminator: String = "\n") {
            if flag > 0 {
                // Commenting these out has no effect
                let str = items.map{String(describing: $0)}.joined(separator: separator)
                print(str, terminator: terminator)
            }
        }
        
        class ViewController: UIViewController {
            var notificationTimer = DispatchWorkItem(block: {} )
        
            override func viewDidLoad() {
                super.viewDidLoad()
                // Do any additional setup after loading the view.
                LOG(1, "Does it get called?", 5, 7, expensiveFunc())        // Segmentation fault
                //LOG(0, "Does it get called?", expensiveFunc())            // OK
            }
        
            func expensiveFunc() -> String {
                print("CALLED")
                return "EXPENSIVE!!!"
            }
        }

        Fault:

        <unknown>:0: error: unable to execute command: Segmentation fault: 11

        <unknown>:0: error: compile command failed due to signal 11 (use -v to see invocation)

         

        Xcode 11.2, Mac -> latest Catalina, Target iPhone 13.2

         

        Where should I enter the bug report? Also, is there a workaround for this?