www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1950] New: CTFE doesn't work correctly for structs passed by ref

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1950

           Summary: CTFE doesn't work correctly for structs passed by ref
           Product: D
           Version: 2.012
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: samukha voliacable.com


struct S
{
    int x;
}

int foo()
{
    S s;
    bar(s);
    return s.x;
}

void bar(ref S s)
{
    s.x = 10;
}

enum x = foo();
static assert(x == 10); // Fails, x is 0


-- 
Mar 26 2008
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1950


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug yahoo.com.au
            Version|2.012                       |1.020




--- Comment #1 from Don <clugdbug yahoo.com.au>  2009-08-17 02:13:20 PDT ---
This bug also applies to D1.0, replacing the 'enum' with 
const int x = foo();

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 17 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1950





--- Comment #2 from Don <clugdbug yahoo.com.au>  2009-08-21 00:20:15 PDT ---
I have fixed this in my copy of interpret.c, but it's rather more general. It
allows arbitrary expressions as reference parameters. (Passing an array member
by reference will result in wrong-code in DMD1.046).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 21 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1950


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch




--- Comment #3 from Don <clugdbug yahoo.com.au>  2009-08-25 00:52:15 PDT ---
I have sent Walter my patch for this, it will be in the next release.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 25 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1950


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED




--- Comment #4 from Walter Bright <bugzilla digitalmars.com>  2009-09-03
13:23:39 PDT ---
Fixed dmd 1.047 and 2.032

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