www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8400] New: static array type cannot interpret dynamic array length

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

           Summary: static array type cannot interpret dynamic array
                    length
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: timon.gehr gmx.ch


--- Comment #0 from timon.gehr gmx.ch 2012-07-18 15:56:56 PDT ---
DMD 2.059:

void main(){
    immutable a = [1,2];
    int[a.length+0] b; // ok
    int[a.length  ] c; // error
}

The code should compile.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 18 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8400


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull, rejects-valid


--- Comment #1 from Kenji Hara <k.hara.pg gmail.com> 2012-07-19 08:49:18 PDT ---
https://github.com/D-Programming-Language/dmd/pull/1058

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 19 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8400



--- Comment #2 from github-bugzilla puremagic.com 2012-07-19 23:53:42 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/b4b6211c519cc744c83e2985fcfaafe68c0fad19
fix Issue 8400 - static array type cannot interpret dynamic array length

Local variables always should be interpreted to detect whether it is really
constant expression or not.

https://github.com/D-Programming-Language/dmd/commit/0dad66820b826d4ee55a82f0a692548c5bd511af
Merge pull request #1058 from 9rnsr/fix8400

Issue 8400 - static array type cannot interpret dynamic array length

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 19 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8400


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc


--- Comment #3 from bearophile_hugs eml.cc 2012-07-23 08:47:04 PDT ---
 void main(){
     immutable a = [1,2];
     int[a.length+0] b; // ok
     int[a.length  ] c; // error
 }
 
 The code should compile.
That code should not compile, in my opinion. Nor this one: immutable a = [1, 2]; void main() { int[a.length] b; } See some discussion: http://forum.dlang.org/thread/xjxkyokzwggfnrvmgziu forum.dlang.org -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 23 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8400


Don <clugdbug yahoo.com.au> changed:

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


--- Comment #4 from Don <clugdbug yahoo.com.au> 2012-07-25 03:39:21 PDT ---
(In reply to comment #3)
 void main(){
     immutable a = [1,2];
     int[a.length+0] b; // ok
     int[a.length  ] c; // error
 }
 
 The code should compile.
That code should not compile, in my opinion.
The rule is, in any circumstance where a compile-time value is required, it will attempt to interpret it at compile time. If it fails, it is an error.
 Nor this one:
 
 immutable a = [1, 2];
 void main() {
     int[a.length] b;
 }
No, that should *definitely* compile. Global variables with initializers always have the initializer CTFE'd. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 25 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8400


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |regression


--- Comment #5 from bearophile_hugs eml.cc 2012-07-25 07:19:15 PDT ---
(In reply to comment #4)

 That code should not compile, in my opinion.
The rule is, in any circumstance where a compile-time value is required, it will attempt to interpret it at compile time. If it fails, it is an error.
I am not sure, but I think you are agreeing with me, so I mark this as a regression.
 Global variables with initializers always have the initializer CTFE'd.
OK. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 25 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8400


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
           Severity|regression                  |normal


--- Comment #6 from Kenji Hara <k.hara.pg gmail.com> 2012-07-25 08:36:03 PDT ---
bearophile's marking as 'regression' is invalid.
My explanation is here: http://d.puremagic.com/issues/show_bug.cgi?id=8312#c5

Then I revert the importance to 'normal', and mark as 'resolved fixed'.

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



--- Comment #7 from Don <clugdbug yahoo.com.au> 2012-07-26 01:35:52 PDT ---
(In reply to comment #5)
 (In reply to comment #4)
 
 That code should not compile, in my opinion.
The rule is, in any circumstance where a compile-time value is required, it will attempt to interpret it at compile time. If it fails, it is an error.
I am not sure, but I think you are agreeing with me, so I mark this as a regression.
I was disagreeing with you. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 26 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8400



--- Comment #8 from github-bugzilla puremagic.com 2013-06-01 00:59:57 PDT ---
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/50569d88e7b0ccf8d786b65bf4f0321fd2698fd2
CTFE: Don't save local variables in the global constants list

Even if they are immutable local variables (eg, bug 8400)

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