www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2080] New: Static variable without explicit type causes compiler to crash

reply d-bugmail puremagic.com writes:
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 08 2008
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2080






Compiles if the declaration of s goes after foo definition


-- 
May 09 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2080






This does work with dmd 2.013.


-- 
May 11 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2080






Right, but the bug is in the 1.x branch, which is still in use :) 


-- 
May 11 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
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





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
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2080






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: -------
May 26 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
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




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: -------
Nov 10 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
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                   |



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: -------
Nov 17 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2080


Don <clugdbug yahoo.com.au> changed:

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



Fixed svn 755.

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