-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
Labels
SILGenArea → compiler: The SIL generation stageArea → compiler: The SIL generation stageassertion failureBug → crash: An assertion failureBug → crash: An assertion failurebugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.crashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwarefor-in loopsFeature: for-in loopsFeature: for-in loopsgenericsFeature: generic declarations and typesFeature: generic declarations and typespack iterationFeature → statements → for-in: Pack iterationFeature → statements → for-in: Pack iterationparameter packsFeature → generics: Parameter packsFeature → generics: Parameter packsstatementsFeature: statementsFeature: statementsswift 6.0
Description
Description
No response
Reproduction
@usableFromInline
enum SortOrder {
case ascending
case descending
}
@inlinable @inline(__always)
func isLessThan<Root, each Value: Comparable>(
_ leftRoot: Root,
_ rightRoot: Root,
comparing properties: repeat ((Root) -> each Value, SortOrder)
) -> Bool {
// Hopefully this will get constant-folded.
var numProperties = 0
for _ in repeat each properties {
numProperties += 1
}
var propertyIdx = 0
for (getProperty, mode) in repeat each properties {
let (left, right) = (getProperty(leftRoot), getProperty(rightRoot))
if propertyIdx < numProperties {
guard left != right else {
propertyIdx += 1
continue
}
}
switch mode {
case .ascending: return left < right
case .descending: return left > right
}
}
return false
}I built with -O, but with/without that flag, it seems to crash the compiler in the same spot.
Stack dump
swift-frontend: /home/build-user/swift/include/swift/SIL/SILBuilder.h:3024: void swift::SILBuilder::insertImpl(swift::SILInstruction *): Assertion `hasValidInsertionPoint()' failed.
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0. Program arguments: /opt/compiler-explorer/swift-nightly/usr/bin/swift-frontend -frontend -S -primary-file <source> -target x86_64-unknown-linux-gnu -disable-objc-interop -g -debug-info-format=dwarf -dwarf-version=4 -O -empty-abi-descriptor -resource-dir /opt/compiler-explorer/swift-nightly/usr/lib/swift -Xllvm --x86-asm-syntax=intel -module-name output -plugin-path /opt/compiler-explorer/swift-nightly/usr/lib/swift/host/plugins -plugin-path /opt/compiler-explorer/swift-nightly/usr/local/lib/swift/host/plugins -enable-default-cmo -o /app/output.s
1. Swift version 5.11-dev (LLVM 170b778140971f1, Swift 9b5da0d82fca791)
2. Compiling with the current language version
3. While evaluating request ASTLoweringRequest(Lowering AST to SIL for file "<source>")
4. While silgen emitFunction SIL function "@$s6output10isLessThan__9comparingSbx_xq_xc_AA9SortOrderOtq_QptRv_SLR_r0_lF".
for 'isLessThan(_:_:comparing:)' (at <source>:12:1)
Expected behavior
Describe the behavior you expected instead of the crash.
Err... no crash, of course :)
Environment
Swift version 5.11-dev (LLVM 170b778140971f1, Swift 9b5da0d)
Target: x86_64-unknown-linux-gnu
Additional information
No response
Metadata
Metadata
Assignees
Labels
SILGenArea → compiler: The SIL generation stageArea → compiler: The SIL generation stageassertion failureBug → crash: An assertion failureBug → crash: An assertion failurebugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.crashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwarefor-in loopsFeature: for-in loopsFeature: for-in loopsgenericsFeature: generic declarations and typesFeature: generic declarations and typespack iterationFeature → statements → for-in: Pack iterationFeature → statements → for-in: Pack iterationparameter packsFeature → generics: Parameter packsFeature → generics: Parameter packsstatementsFeature: statementsFeature: statementsswift 6.0