Skip to content

Fixes [SR-78] swift compiler seg fault #293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 7, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/IRGen/GenType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2031,8 +2031,9 @@ SILType irgen::getSingletonAggregateFieldType(IRGenModule &IGM,

// If there's only one stored property, we have the layout of its field.
auto allFields = structDecl->getStoredProperties();

auto field = allFields.begin();
if (std::next(field) == allFields.end())
if (!allFields.empty() && std::next(field) == allFields.end())
return t.getFieldType(*field, *IGM.SILMod);

return SILType();
Expand Down
26 changes: 26 additions & 0 deletions test/IRGen/generic_structs.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// RUN: %target-swift-frontend -primary-file %s -emit-ir | FileCheck %s

struct A<T1, T2>
{
var b: T1
var c: T2
var d: B<T1, T2>
}
struct B<T1, T2>
{
var c: T1
var d: T2
}

struct C<T1>
{}
struct D<T2>
{}

struct Foo<A1, A2>
{
var b: Bar<A1, A2>
}

struct Bar {
}