Thread overview
[Issue 2080] New: Static variable without explicit type causes compiler to crash
May 08, 2008
d-bugmail
May 09, 2008
d-bugmail
May 11, 2008
d-bugmail
May 12, 2008
d-bugmail
[Issue 2080] Segfault(D1 only, mangle.c) alias corrupts type inference of static variables
May 26, 2009
Don
May 26, 2009
Don
[Issue 2080] ICE(D1 only, mangle.c) alias corrupts type inference of static variables
Nov 10, 2009
Don
[Issue 2080] ICE(mangle.c) alias corrupts type inference of static variables
Nov 18, 2009
Don
Nov 15, 2010
Don
May 08, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2080

           Summary: Static variable without explicit type causes compiler to
                    crash
           Product: D
           Version: 1.029
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: samukha@voliacable.com


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;
}


-- 

May 09, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2080





------- Comment #1 from samukha@voliacable.com  2008-05-09 07:07 -------
Compiles if the declaration of s goes after foo definition


-- 

May 11, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2080





------- Comment #2 from bugzilla@digitalmars.com  2008-05-11 18:45 -------
This does work with dmd 2.013.


-- 

May 12, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2080





------- Comment #3 from samukha@voliacable.com  2008-05-12 00:59 -------
Right, but the bug is in the 1.x branch, which is still in use :)


-- 

May 26, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2080


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug@yahoo.com.au
            Summary|Static variable without     |Segfault(D1 only, mangle.c)
                   |explicit type causes        |alias corrupts type
                   |compiler to crash           |inference of static
                   |                            |variables
           Severity|normal                      |critical




--- Comment #4 from Don <clugdbug@yahoo.com.au>  2009-05-26 11:35:06 PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 26, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2080





--- Comment #5 from Don <clugdbug@yahoo.com.au>  2009-05-26 11:57:36 PDT ---
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;

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 10, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2080


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Segfault(D1 only, mangle.c) |ICE(D1 only, mangle.c)
                   |alias corrupts type         |alias corrupts type
                   |inference of static         |inference of static
                   |variables                   |variables


--- Comment #6 from Don <clugdbug@yahoo.com.au> 2009-11-10 02:06:45 PST ---
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;
----

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 18, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2080


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|ICE(D1 only, mangle.c)      |ICE(mangle.c) alias
                   |alias corrupts type         |corrupts type inference of
                   |inference of static         |static variables
                   |variables                   |


--- Comment #7 from Don <clugdbug@yahoo.com.au> 2009-11-17 23:56:15 PST ---
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;

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 15, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=2080


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


--- Comment #8 from Don <clugdbug@yahoo.com.au> 2010-11-15 00:04:15 PST ---
Fixed svn 755.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------