Thread overview
[Issue 3730] New: Struct's explicit constructor can't initialize global variables
Jan 20, 2010
Tomasz Sowiński
Jan 20, 2010
Don
Jan 21, 2010
Tomasz Sowiński
Jun 13, 2011
yebblies
January 20, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3730

           Summary: Struct's explicit constructor can't initialize global
                    variables
           Product: D
           Version: 2.039
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: tomeksowi@gmail.com


--- Comment #0 from Tomasz Sowiński <tomeksowi@gmail.com> 2010-01-20 12:20:09 PST ---
Test case:

struct S {
    int a;
    this(int a) {
        this.a = a;
    }
    static immutable S es = S(3);
}

Compiler output (message printed twice in original):
test.d|9|Error: cannot evaluate ((S __ctmp516;
test.d|9|Error: cannot evaluate ((S __ctmp516;

Don't know if that should compile but surely the message could be more appealing.

static this() may be used as a workaround for this bug.

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


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug@yahoo.com.au


--- Comment #1 from Don <clugdbug@yahoo.com.au> 2010-01-20 12:55:03 PST ---
This works for me in DMD2.039 Windows svn 342. (Are you sure you're not using
2.038?)

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



--- Comment #2 from Tomasz Sowiński <tomeksowi@gmail.com> 2010-01-21 10:56:04 PST ---
(In reply to comment #1)
> This works for me in DMD2.039 Windows svn 342. (Are you sure you're not using
> 2.038?)

Yes, I even compiled from command line to make sure.

C:\Projekty\Witajki\Witaj Phobosie>dmd
Digital Mars D Compiler v2.039
Copyright (c) 1999-2009 by Digital Mars written by Walter Bright
Documentation: http://www.digitalmars.com/d/2.0/index.html
[snip]

C:\Projekty\Witajki\Witaj Phobosie>dmd test.d
test.d(8): Error: cannot evaluate ((S __ctmp1;
) , __ctmp1).this(3) at compile time
test.d(8): Error: cannot evaluate ((S __ctmp1;
) , __ctmp1).this(3) at compile time

There's more output after newline which CodeBlocks didn't pick up.

I don't know the SVN rev. of my DMD, though. Maybe sb fixed that after the release?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 13, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3730


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |yebblies@gmail.com
         Resolution|                            |FIXED


--- Comment #3 from yebblies <yebblies@gmail.com> 2011-06-12 22:46:24 PDT ---
This compiles without error in dmd2.053

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