D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3494 - Segfault(mtype.c) using typeof(return) inside an auto function
Summary: Segfault(mtype.c) using typeof(return) inside an auto function
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other All
: P2 normal
Assignee: No Owner
URL:
Keywords: ice-on-invalid-code, patch
Depends on:
Blocks:
 
Reported: 2009-11-11 05:21 UTC by Don
Modified: 2015-06-09 01:27 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Don 2009-11-11 05:21:25 UTC
TEST CASE:
---
auto foo()
{
    typeof(return) result;
    return result;
}
---

PATCH: TypeReturn::semantic(), mtype.c, line 5236

Type *TypeReturn::semantic(Loc loc, Scope *sc)
{
    Type *t;
    if (!sc->func)
    {	error(loc, "typeof(return) must be inside function");
	goto Lerr;
    }
    t = sc->func->type->nextOf();
+    if (!t)
+    {   error(loc, "typeof(return) cannot infer type");
+        goto Lerr;
+    }
    t = t->addMod(mod);
Comment 1 Walter Bright 2009-12-06 00:54:47 UTC
Fixed dmd 2.037