Thread overview
[Issue 9818] New: Constant folding for static array does not work with initializing by element
Mar 26, 2013
Kenji Hara
Mar 26, 2013
Kenji Hara
Mar 30, 2013
Walter Bright
March 26, 2013
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


--- Comment #0 from Kenji Hara <k.hara.pg@gmail.com> 2013-03-26 07:32:31 PDT ---
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: -------
March 26, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9818


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

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


--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> 2013-03-26 09:00:12 PDT ---
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: -------
March 30, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9818



--- Comment #2 from github-bugzilla@puremagic.com 2013-03-30 16:20:28 PDT ---
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 Merge pull request #1801 from 9rnsr/fix9818

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: -------
March 30, 2013
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: -------