www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6517] New: [CTFE] ptr++ doesn't work but ++ptr does

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

           Summary: [CTFE] ptr++ doesn't work but ++ptr does
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: dsimcha yahoo.com



int ctfeFun(const int[] arr) {
    auto startp = arr.ptr;
    auto endp = arr.ptr + arr.length;

    for(; startp < endp; startp++) {}

    return 0;
}

const arr = [1, 2, 3];
enum ans = ctfeFun(arr);

test9.d(5): Error: pointer expression startp++ cannot be interpreted at compile
time
test9.d(11): Error: cannot evaluate ctfeFun(arr) at compile time

Changing startp++ to ++startp fixes the problem.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 17 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6517


nsf <no.smile.face gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |no.smile.face gmail.com



I can confirm it. But in my case it's 'p--' which cannot be interpreted at
compile-time, when ++p somewhere in the code works just fine. 'p' is
'const(char)*'.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 17 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6517


Walter Bright <bugzilla digitalmars.com> changed:

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



22:46:52 PDT ---
https://github.com/D-Programming-Language/dmd/commit/563a291a5c7757fca87685909afa37100e3b44f6

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