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

Compiler crashes if overloaded method signature contains varargs followed by a second parameter

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Medium
    • Resolution: Duplicate
    • Component/s: Compiler
    • Environment:

      swift version:
      Apple Swift version 3.1 (swiftlang-802.0.36.2 clang-802.0.35)
      Target: x86_64-apple-macosx10.9

      Description

      The following code will crash the swift compiler (and REPL):

      func foo(foo: [Int], bar: Int) {
      }
      func foo(foo: Int..., bar: Int) {
      }
      

      This issue appears if the first argument of the first function is an array of any type and the first argument of the second function is a variadic argument of the same type.

      The second argument is required on both methods for the issue to appear and the type of the second argument must be the same on both methods, but it does not need to match the type of the first argument.

      Initializers of structs and classes are also affected.

      The swift compiler produces the following output when called with the -v flag:

      Apple Swift version 3.1 (swiftlang-802.0.36.2 clang-802.0.35)
      Target: x86_64-apple-macosx10.9
      /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file bug.swift -target x86_64-apple-macosx10.9 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -color-diagnostics -module-name bug -o /var/folders/_z/r4w3qsxd51z_2r9ww94k5z6w0000gn/T/bug-ee7056.o
      0  swift                    0x00000001117527a7 PrintStackTraceSignalHandler(void*) + 39
      1  swift                    0x0000000111751d36 SignalHandler(int) + 662
      2  libsystem_platform.dylib 0x00007fff96627bba _sigtramp + 26
      3  libsystem_platform.dylib 000000000000000000 _sigtramp + 1771930720
      4  swift                    0x000000010f0a6287 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*)::$_1::operator()(swift::SILFunction*) const + 1191
      5  swift                    0x000000010f0a5102 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 642
      6  swift                    0x000000010f0b3a81 swift::ASTVisitor<swift::Lowering::SILGenModule, void, void, void, void, void, void>::visit(swift::Decl*) + 657
      7  swift                    0x000000010f0b2b3b swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*, unsigned int) + 1483
      8  swift                    0x000000010f0b4719 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool, bool) + 1593
      9  swift                    0x000000010e9d93f2 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 45842
      10 swift                    0x000000010e9893c2 main + 11298
      11 libdyld.dylib            0x00007fff9641a255 start + 1
      Stack dump:
      0.	Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file bug.swift -target x86_64-apple-macosx10.9 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -color-diagnostics -module-name bug -o /var/folders/_z/r4w3qsxd51z_2r9ww94k5z6w0000gn/T/bug-ee7056.o 
      1.	While emitting SIL for 'foo' at bug.swift:3:1
      <unknown>:0: error: unable to execute command: Segmentation fault: 11
      <unknown>:0: error: compile command failed due to signal (use -v to see invocation)
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                palle Palle Klewitz
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: