Bug 2080 – ICE(mangle.c) alias corrupts type inference of static variables

Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2008-05-08T06:54:00Z
Last change time
2014-02-24T15:33:13Z
Keywords
ice-on-valid-code
Assigned to
bugzilla
Creator
samukha
Blocks
340

Comments

Comment #0 by samukha — 2008-05-08T06:54:47Z
const s = foo(); // compiles if type of s is specified explicitly char[] foo() // seems to fail only if the return type is char[] { return null; }
Comment #1 by samukha — 2008-05-09T07:07:10Z
Compiles if the declaration of s goes after foo definition
Comment #2 by bugzilla — 2008-05-11T18:45:11Z
This does work with dmd 2.013.
Comment #3 by samukha — 2008-05-12T00:59:47Z
Right, but the bug is in the 1.x branch, which is still in use :)
Comment #4 by clugdbug — 2009-05-26T11:35:06Z
The test case is a bit misleading. It requires an alias to the type which is being inferred. With the original test case, it was provided by alias char[] string; in std.object. Here's a complete test case. Remove the alias, and it will be fine. --- alias int * any_old_alias; const bar = foo; int * foo = null; --- The alias creates a corrupt type (it doesn't have the 'deco' member set), and this gets picked by 'bar' instead of the type of foo. The behaviour is quite similar to 2672. Marking as critical, because subtle changes in ordering in different modules can control whether the segfault occurs.
Comment #5 by clugdbug — 2009-05-26T11:57:36Z
Aargh, I'm wrong, it just has to be any forward reference. This really simple test case segfaults in a completely different place (cast.c), with a much more obviously corrupt type. const bar = foo; const int * foo = null;
Comment #6 by clugdbug — 2009-11-10T02:06:45Z
I've moved the new test case to bug#3493 (segfault, cast.c). The original bug now generates a forward reference error; the reduced test case (below) is now an ICE instead of a segfault. This should be considered as the test-case for this bug. ---- alias int * any_old_alias; const bar = foo; int * foo = null; ----
Comment #7 by clugdbug — 2009-11-17T23:56:15Z
This applies to D2 as well. The D2 test case (below) generates: "Error: forward reference to type int*" on D1. On D2 it ICEs in mangle.c(81) fd && fd->inferRetType Removing the alias fixes both the ICE and the forward reference error. Happens with typedef as well as alias. ----- alias int * any_old_alias; typeof(foo) bar = foo; const int * foo = null;
Comment #8 by clugdbug — 2010-11-15T00:04:15Z
Fixed svn 755.