www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - newCTFE report July

reply Stefan Koch <uplink.coder googlemail.com> writes:
Hi Guys, last month I did the work make this snippet compile and 
execute correctly:

static immutable four = [1, 2, 3, 4];
int fn(int idx = 2)
{
     int fn2(const int* x)
     {
       return x[idx];
     }

     return fn2(&four[0]) + *(&four[0]);
}

static assert(fn() == 4);


There where two major problems with this one.

1. There was the circular initialization-detected which would 
object to referencing `&four` twice in the same expression.

2. there was the problem of the IndexExp being unaware of being 
inside an AddrExp which would cause it to first evaluate four[0] 
to 1, and then trying to take the address of literal one (which 
is zero as the marker for an invalid address).

Fixing this involved adding a special case to how &x[y] is 
handled.
This solution does complicate the internals of newCTFE a bit, and 
I hope to simplify it once other blocking problems are out of the 
way.
Jul 18 2018
next sibling parent reply "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Wed, Jul 18, 2018 at 06:28:30PM +0000, Stefan Koch via Digitalmars-d wrote:
[...]

Good to hear that progress on newCTFE is still being made.

What's your current estimate on when it will be production-ready?


T

-- 
Democracy: The triumph of popularity over principle. -- C.Bond
Jul 18 2018
parent reply Stefan Koch <uplink.coder googlemail.com> writes:
On Wednesday, 18 July 2018 at 18:36:37 UTC, H. S. Teoh wrote:
 On Wed, Jul 18, 2018 at 06:28:30PM +0000, Stefan Koch via 
 Digitalmars-d wrote: [...]

 Good to hear that progress on newCTFE is still being made.

 What's your current estimate on when it will be 
 production-ready?


 T
I am going to give the same conservative answer I gave a Dconf: 2020
Jul 18 2018
parent "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Wed, Jul 18, 2018 at 07:18:52PM +0000, Stefan Koch via Digitalmars-d wrote:
 On Wednesday, 18 July 2018 at 18:36:37 UTC, H. S. Teoh wrote:
[...]
 What's your current estimate on when it will be production-ready?
[...]
 I am going to give the same conservative answer I gave a Dconf: 2020
Can't wait for 2020 to arrive! :-D T -- Doubt is a self-fulfilling prophecy.
Jul 18 2018
prev sibling parent =?UTF-8?Q?Ali_=c3=87ehreli?= <acehreli yahoo.com> writes:
On 07/18/2018 11:28 AM, Stefan Koch wrote:

 2. there was the problem of the IndexExp being unaware of being inside
 an AddrExp which would cause it to first evaluate four[0] to 1, and then
 trying to take the address of literal one (which is zero as the marker
 for an invalid address).
Without knowing much about the compiler, could that be solved by changing four[0] to a reference expression? Is there even such a concept in the compiler? How does the non-CTFE compilation deal with that case? Ali
Jul 18 2018