File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -4110,6 +4110,15 @@ namespace {
41104110 if (ctordecl->isCopyConstructor () || ctordecl->isMoveConstructor ())
41114111 return nullptr ;
41124112
4113+ // Don't import the generic ctors of std::span, rely on the ctors that
4114+ // we instantiate when conforming to the overlay. These generic ctors
4115+ // can cause crashes in codegen.
4116+ // FIXME: figure out why.
4117+ const auto *parent = ctordecl->getParent ();
4118+ if (funcTemplate && parent->isInStdNamespace () &&
4119+ parent->getIdentifier () && parent->getName () == " span" )
4120+ return nullptr ;
4121+
41134122 DeclName ctorName (Impl.SwiftContext , DeclBaseName::createConstructor (),
41144123 bodyParams);
41154124 result = Impl.createDeclWithClangNode <ConstructorDecl>(
Original file line number Diff line number Diff line change @@ -11,3 +11,11 @@ arr.withUnsafeBufferPointer { ubpointer in
1111 let _ = ConstSpanOfInt ( ubpointer. baseAddress!, ubpointer. count)
1212 // expected-warning@-1 {{'init(_:_:)' is deprecated: use 'init(_:)' instead.}}
1313}
14+
15+ arr. withUnsafeBufferPointer { ubpointer in
16+ // FIXME: this crashes the compiler once we import span's templated ctors as Swift generics.
17+ let _ = ConstSpanOfInt ( ubpointer. baseAddress, ubpointer. count)
18+ // expected-error@-1 {{value of optional type 'UnsafePointer<Int32>?' must be unwrapped to a value of type 'UnsafePointer<Int32>'}}
19+ // expected-note@-2 {{coalesce using '??' to provide a default when the optional value contains 'nil'}}
20+ // expected-note@-3 {{force-unwrap using '!' to abort execution if the optional value contains 'nil'}}
21+ }
You can’t perform that action at this time.
0 commit comments