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



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



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




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


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



 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




 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





 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



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






 
 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




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