www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1625] New: cannot evaluate function compile-time when return type includes a union

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

           Summary: cannot evaluate function  compile-time when return type
                    includes a union
           Product: D
           Version: 2.006
          Platform: PC
               URL: http://paste.dprogramming.com/dpjhoxzy
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: spam extrawurst.org


dmd refuses to compile the following legal code:

[CODE]
struct Foo {

    union {
        struct {
            float x,y,z;
        }
        float[3] _v;
    }

    static Foo bar(){
        Foo f;
        return f;
    }
}

void main() {
    const Foo foo = Foo.bar();//Error: cannot evaluate bar() at compile time
}
[/CODE]

i hope i am right that it should work and is valid code.


-- 
Oct 29 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1625





------- Comment #1 from spam extrawurst.org  2007-11-28 03:37 -------
this examples seems to work now, was it intentionally fixed in 2.008? it's not
in the changelog.


-- 
Nov 28 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1625


spam extrawurst.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |spam extrawurst.org




------- Comment #2 from spam extrawurst.org  2007-11-29 06:56 -------
ok the above example works under dmd2.008 just cause of the changes in the
const thing, when involving static it isnt able to evaluate the union stuff
 compile time again:

[CODE]
struct Foo {

    union {
        struct {
            float x,y,z;
        }
        float[3] _v;
    }

    static Foo bar(){
        Foo f;
        return f;
    }
}

void main() {
    static Foo foo = Foo.bar();//Error: cannot evaluate bar() at compile time
}
[/CODE]


-- 
Nov 29 2007
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1625


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug yahoo.com.au
            Summary|cannot evaluate function    |CTFE: cannot evaluate
                   | compile-time when return   |function when return type
                   |type includes a union       |includes a union




--- Comment #3 from Don <clugdbug yahoo.com.au>  2009-08-26 09:45:28 PDT ---
Actually it cannot evaluate any function which involves reading the value of a
union. (It can WRITE to a union, though!)

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