www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9818] New: Constant folding for static array does not work with initializing by element

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

           Summary: Constant folding for static array does not work with
                    initializing by element
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: k.hara.pg gmail.com



Test case:

static const int[3] sa1 = 1;
pragma(msg, "sa1: ", sa1);          // doesn't work
static assert(sa1 == [1, 1, 1]);    // doesn't work

enum int[3] ea1 = 1;
pragma(msg, "ea1: ", ea1);          // prints "1" - bad
static assert(ea1 == [1, 1, 1]);    // doesn't work

struct X
{
    static const int[3] sa2 = 1;
    pragma(msg, "sa2: ", sa1);          // doesn't work
    static assert(sa2 == [1, 1, 1]);    // doesn't work

    enum int[3] ea2 = 1;
    pragma(msg, "ea2: ", ea2);          // prints "1" - bad
    static assert(ea2 == [1, 1, 1]);    // doesn't work
}
void test()
{
    static const int[3] sa3 = 1;
    pragma(msg, "sa3: ", sa3);          // doesn't work
    static assert(sa3 == [1, 1, 1]);    // doesn't work

    enum int[3] ea3 = 1;
    pragma(msg, "ea3: ", ea3);          // prints "1" - bad
    static assert(ea3 == [1, 1, 1]);    // doesn't work

    struct Y
    {
        static const int[3] sa4 = 1;
        pragma(msg, "sa4: ", sa4);          // doesn't work
        static assert(sa4 == [1, 1, 1]);    // doesn't work

        enum int[3] ea4 = 1;
        pragma(msg, "ea4: ", ea4);          // prints "1" - bad
        static assert(ea4 == [1, 1, 1]);    // doesn't work
    }
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 26 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9818


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull



https://github.com/D-Programming-Language/dmd/pull/1801

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 26 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9818




Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/818fbf70501d7d6bc9cb8ed902f1b5b779f5bd10
fix Issue 9818 - Constant folding for static array does not work with
initializing by element

Refactoring code for initializer semantic.

- Handle implicit constructor call in ExpInitializer::semantic
- Add target type parameter in Initializer::toExpression.
  For `T[n] sa = e;`, its initializer translation to [e1, e2, ..., en] is
delayed until it's really needed.

https://github.com/D-Programming-Language/dmd/commit/8d482641c862de6285a6c20aab7127370912fa7a


Issue 9818 - Constant folding for static array does not work with initializing
by element

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 30 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9818


Walter Bright <bugzilla digitalmars.com> changed:

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


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