Commit 53c66543 authored by Russ Cox's avatar Russ Cox

cmd/gc: avoid infinite recursion on invalid recursive type

Fixes #8507.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews, r
https://golang.org/cl/144560043
parent 1aa65fe8
......@@ -119,8 +119,10 @@ dowidth(Type *t)
if(t->width == -2) {
lno = lineno;
lineno = t->lineno;
if(!t->broke)
if(!t->broke) {
t->broke = 1;
yyerror("invalid recursive type %T", t);
}
t->width = 0;
lineno = lno;
return;
......
......@@ -529,7 +529,8 @@ algtype1(Type *t, Type **bad)
if(bad)
*bad = T;
if(t->broke)
return AMEM;
if(t->noalg)
return ANOEQ;
......
// errorcheck
// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// issue 8507
// used to call algtype on invalid recursive type and get into infinite recursion
package p
type T struct{ T } // ERROR "invalid recursive type T"
func f() {
println(T{} == T{})
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment