Skip to content

[SR-11532] swiftc crash with Magnitude constraints on both type and init #53933

@mayoff

Description

@mayoff
Previous ID SR-11532
Radar rdar://problem/55758433
Original Reporter @mayoff
Type Bug
Status Resolved
Resolution Done
Environment

swift-DEVELOPMENT-SNAPSHOT-2019-09-25-a.xctoolchain
Xcode-11.1 GM Seed
macOS 10.14.6 (18G95)

Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug, CompilerCrash
Assignee None
Priority Medium

md5: c67ea7b44239d12d0a53f22a15213f3b

relates to:

  • SR-11531 strange error: 'Test' requires the types 'E' and 'E.Magnitude' be equivalent

Issue Description:

The compiler crashes on the following:

public struct Test<E: BinaryInteger> where E.Magnitude == E {
    var x: Int = 0
    init<F: BinaryInteger>(_: F) where F.Magnitude == E {
    }
}

Here is the crash log:

Assertion failed: (is<T>() && "Invalid accessor called"), function get, file /Users/buildnode/jenkins/workspace/oss-swift-package-osx/llvm/include/llvm/ADT/PointerUnion.h, line 136.
Stack dump:
0.  Program arguments: /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2019-09-25-a.xctoolchain/usr/bin/swift -frontend -c -primary-file /Volumes/Away - Data/Users/mayoff/TestProjects/test/test/AppDelegate.swift /Volumes/Away - Data/Users/mayoff/TestProjects/test/test/SceneDelegate.swift /Volumes/Away - Data/Users/mayoff/TestProjects/test/test/ContentView.swift -emit-module-path /Users/mayoff/Library/Developer/Xcode/DerivedData/test-adowgcsbaerhtsetwroadwbzcnyb/Build/Intermediates.noindex/test.build/Debug-iphoneos/test.build/Objects-normal/arm64/AppDelegate~partial.swiftmodule -emit-module-doc-path /Users/mayoff/Library/Developer/Xcode/DerivedData/test-adowgcsbaerhtsetwroadwbzcnyb/Build/Intermediates.noindex/test.build/Debug-iphoneos/test.build/Objects-normal/arm64/AppDelegate~partial.swiftdoc -emit-module-source-info-path /Users/mayoff/Library/Developer/Xcode/DerivedData/test-adowgcsbaerhtsetwroadwbzcnyb/Build/Intermediates.noindex/test.build/Debug-iphoneos/test.build/Objects-normal/arm64/AppDelegate~partial.swiftsourceinfo -serialize-diagnostics-path /Users/mayoff/Library/Developer/Xcode/DerivedData/test-adowgcsbaerhtsetwroadwbzcnyb/Build/Intermediates.noindex/test.build/Debug-iphoneos/test.build/Objects-normal/arm64/AppDelegate.dia -emit-dependencies-path /Users/mayoff/Library/Developer/Xcode/DerivedData/test-adowgcsbaerhtsetwroadwbzcnyb/Build/Intermediates.noindex/test.build/Debug-iphoneos/test.build/Objects-normal/arm64/AppDelegate.d -emit-reference-dependencies-path /Users/mayoff/Library/Developer/Xcode/DerivedData/test-adowgcsbaerhtsetwroadwbzcnyb/Build/Intermediates.noindex/test.build/Debug-iphoneos/test.build/Objects-normal/arm64/AppDelegate.swiftdeps -target arm64-apple-ios13.1 -Xllvm -aarch64-use-tbi -enable-objc-interop -sdk /Applications/Xcode-11.1GM1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.1.sdk -I /Users/mayoff/Library/Developer/Xcode/DerivedData/test-adowgcsbaerhtsetwroadwbzcnyb/Build/Products/Debug-iphoneos -F /Users/mayoff/Library/Developer/Xcode/DerivedData/test-adowgcsbaerhtsetwroadwbzcnyb/Build/Products/Debug-iphoneos -enable-testing -g -module-cache-path /Users/mayoff/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -swift-version 5 -enforce-exclusivity=checked -Onone -D DEBUG -serialize-debugging-options -enable-anonymous-context-mangled-names -Xcc -I/Users/mayoff/Library/Developer/Xcode/DerivedData/test-adowgcsbaerhtsetwroadwbzcnyb/Build/Intermediates.noindex/test.build/Debug-iphoneos/test.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/mayoff/Library/Developer/Xcode/DerivedData/test-adowgcsbaerhtsetwroadwbzcnyb/Build/Intermediates.noindex/test.build/Debug-iphoneos/test.build/test-generated-files.hmap -Xcc -I/Users/mayoff/Library/Developer/Xcode/DerivedData/test-adowgcsbaerhtsetwroadwbzcnyb/Build/Intermediates.noindex/test.build/Debug-iphoneos/test.build/test-own-target-headers.hmap -Xcc -I/Users/mayoff/Library/Developer/Xcode/DerivedData/test-adowgcsbaerhtsetwroadwbzcnyb/Build/Intermediates.noindex/test.build/Debug-iphoneos/test.build/test-all-target-headers.hmap -Xcc -iquote -Xcc /Users/mayoff/Library/Developer/Xcode/DerivedData/test-adowgcsbaerhtsetwroadwbzcnyb/Build/Intermediates.noindex/test.build/Debug-iphoneos/test.build/test-project-headers.hmap -Xcc -I/Users/mayoff/Library/Developer/Xcode/DerivedData/test-adowgcsbaerhtsetwroadwbzcnyb/Build/Products/Debug-iphoneos/include -Xcc -I/Users/mayoff/Library/Developer/Xcode/DerivedData/test-adowgcsbaerhtsetwroadwbzcnyb/Build/Intermediates.noindex/test.build/Debug-iphoneos/test.build/DerivedSources-normal/arm64 -Xcc -I/Users/mayoff/Library/Developer/Xcode/DerivedData/test-adowgcsbaerhtsetwroadwbzcnyb/Build/Intermediates.noindex/test.build/Debug-iphoneos/test.build/DerivedSources/arm64 -Xcc -I/Users/mayoff/Library/Developer/Xcode/DerivedData/test-adowgcsbaerhtsetwroadwbzcnyb/Build/Intermediates.noindex/test.build/Debug-iphoneos/test.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -working-directory/Volumes/Away - Data/Users/mayoff/TestProjects/test -module-name test -o /Users/mayoff/Library/Developer/Xcode/DerivedData/test-adowgcsbaerhtsetwroadwbzcnyb/Build/Intermediates.noindex/test.build/Debug-iphoneos/test.build/Objects-normal/arm64/AppDelegate.o -index-store-path /Users/mayoff/Library/Developer/Xcode/DerivedData/test-adowgcsbaerhtsetwroadwbzcnyb/Index/DataStore -index-system-modules 
1.  Apple Swift version 5.1-dev (LLVM c5340df2d1, Swift e052da7d88)
2.  While silgen emitConstructor SIL function "@$s4test4TestVyACyxGqd__cSzRd__lufC".
 for 'init(_:)' (at /Volumes/Away - Data/Users/mayoff/TestProjects/test/test/AppDelegate.swift:40:5)
0  swift                    0x000000010d5808e5 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  swift                    0x000000010d57fbd5 llvm::sys::RunSignalHandlers() + 85
2  swift                    0x000000010d580ec8 SignalHandler(int) + 264
3  libsystem_platform.dylib 0x00007fff67b76b5d _sigtramp + 29
4  libsystem_platform.dylib 0x0000000000004718 _sigtramp + 2554911704
5  libsystem_c.dylib        0x00007fff67a306a6 abort + 127
6  libsystem_c.dylib        0x00007fff679f920d basename_r + 0
7  swift                    0x000000010d703633 swift::Lowering::SILGenModule::useConformance(swift::ProtocolConformanceRef) (.cold.1) + 35
8  swift                    0x0000000109fb2e17 swift::Lowering::SILGenModule::useConformance(swift::ProtocolConformanceRef) + 535
9  swift                    0x0000000109fb3404 swift::SILInstructionVisitor<LazyConformanceEmitter, void>::visit(swift::SILInstruction*) + 1060
10 swift                    0x0000000109fb2f93 swift::Lowering::SILGenModule::emitLazyConformancesForFunction(swift::SILFunction*) + 99
11 swift                    0x0000000109f2d3a9 swift::Lowering::SILGenModule::postEmitFunction(swift::SILDeclRef, swift::SILFunction*) + 25
12 swift                    0x0000000109f3452e swift::Lowering::SILGenModule::emitConstructor(swift::ConstructorDecl*)::$_3::operator()(swift::SILFunction*) const + 302
13 swift                    0x0000000109f2c7af swift::Lowering::SILGenModule::emitConstructor(swift::ConstructorDecl*) + 799
14 swift                    0x000000010a003c52 swift::ASTVisitor<(anonymous namespace)::SILGenType, void, void, void, void, void, void>::visit(swift::Decl*) + 514
15 swift                    0x000000010a001a5b (anonymous namespace)::SILGenType::emitType() + 379
16 swift                    0x000000010a0018d9 swift::Lowering::SILGenModule::visitNominalTypeDecl(swift::NominalTypeDecl*) + 25
17 swift                    0x0000000109f312d6 swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*) + 838
18 swift                    0x0000000109f3219a swift::SILModule::constructSIL(swift::ModuleDecl*, swift::Lowering::TypeConverter&, swift::SILOptions&, swift::FileUnit*) + 298
19 swift                    0x0000000109f325d6 swift::performSILGeneration(swift::FileUnit&, swift::Lowering::TypeConverter&, swift::SILOptions&) + 38
20 swift                    0x0000000109c4ec5e performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 7390
21 swift                    0x0000000109c4c050 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3024
22 swift                    0x0000000109bf3a19 main + 729
23 libdyld.dylib            0x00007fff6798b3d5 start + 1
error: Abort trap: 6 (in target 'test' from project 'test')

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of software

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions