Skip to content

IRGen ignores noexcept on function type #73396

Open
@ahatanaka

Description

@ahatanaka

Description

IRGen seems to ignore the noexcept specifier on a C++ function.

Reproduction

$ cat test.h

void (* _Nonnull getFunctionPtr() noexcept)() noexcept;

$ cat test.swift

func test() {
  getFunctionPtr()()
}

$ swift-frontend test.swift -cxx-interoperability-mode=default -emit-irgen

define hidden swiftcc void @"$s4testAAyyF"() #1 personality ptr @__gxx_personality_v0 {
entry:
  %0 = call ptr @_Z14getFunctionPtrv()
  invoke void %0()
          to label %invoke.cont unwind label %exception.unwind

invoke.cont:                                      ; preds = %entry
  ret void

exception.unwind:                                 ; preds = %entry
  %1 = landingpad { ptr, i32 }
          catch ptr null
  call void @llvm.trap()
  unreachable
}

Expected behavior

The invoke instruction should be just a call as the function pointer type is annotated with noexcept.

Environment

Swift version 6.0-dev (LLVM caa3e1810260259, Swift 1306f522b19a58c)
Target: arm64-apple-macosx14.0

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    IRGenLLVM IR generationbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.c++ interopFeature: Interoperability with C++c++ to swiftFeature → c++ interop: c++ to swiftcompilerThe Swift compiler itselfswift 6.0unexpected behaviorBug: Unexpected behavior or incorrect output

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions