Issue 22659 - [REG master] Error: declaration '(S[2] arr = __error__;)' is not yet implemented in CTFE
Summary: [REG master] Error: declaration '(S[2] arr = __error__;)' is not yet implemen...
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 regression
Assignee: No Owner
URL:
Keywords: CTFE, diagnostic, ice-on-invalid-code, pull
Depends on:
Blocks:
 
Reported: 2022-01-08 21:40 UTC by Iain Buclaw
Modified: 2022-01-20 14:37 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Iain Buclaw 2022-01-08 21:40:31 UTC
When there is a mismatch between compiler and run-time, or the body fails to compile for whatever reason, bad errors with the new templated lowerings ensue.

This was caused by recent gagging that is now done in the front-end.

https://github.com/dlang/dmd/pull/13476

---
module object;

alias size_t = typeof(int.sizeof);
extern(C) void* memcpy(return void* s1, scope const void* s2, size_t n) pure;

Tarr1 _d_arrayctor(Tarr1 : T1[], Tarr2 : T2[], T1, T2)(scope Tarr2 from) @trusted
{
    Tarr1 to;
    memcpy(to.ptr, from.ptr, to.length * T1.sizeof);
    *cast(size_t *)&to = from.length;
    return to;
}

bool test9245()
{
    struct S
    {
        this(this) { }
    }

    S[2] arr;
    S[2] arr2 = arr;

    return true;
}
static assert(test9245());
Comment 1 Teodor Dutu 2022-01-10 11:32:26 UTC
This behaviour only happens if the user basically overrides `object._d_arrayctor` with their own hook. But function names starting with `_d_` are reserved for internal usage by the compiler. Isn't this problem overly specific to a use case that is very unlikely to happen?
Comment 2 Iain Buclaw 2022-01-10 14:07:29 UTC
(In reply to Teodor Dutu from comment #1)
> This behaviour only happens if the user basically overrides
> `object._d_arrayctor` with their own hook. But function names starting with
> `_d_` are reserved for internal usage by the compiler. Isn't this problem
> overly specific to a use case that is very unlikely to happen?


1. It should not be possible to ICE the compiler with any code, no matter how improbable it is to have it.  An `__error__` is an internal state that should never leak out to user diagnostics.

2. This happened in all pipelines after someone raised a pull request, that's not an unusual thing to do.
Comment 3 Dlang Bot 2022-01-20 12:43:48 UTC
@teodutu created dlang/dmd pull request #13555 "Fix 22659 - Do not gag semantic errors from `_d_array{,set}ctor`" fixing this issue:

- Fix Issue 22659 - Do not gag semantic errors from `_d_array{,set}ctor`
  
  Signed-off-by: Teodor Dutu <teodor.dutu@gmail.com>

https://github.com/dlang/dmd/pull/13555
Comment 4 Dlang Bot 2022-01-20 14:37:21 UTC
dlang/dmd pull request #13555 "Fix 22659 - Do not gag semantic errors from `_d_array{,set}ctor`" was merged into master:

- 3d622f6613106a5e5ddf30450bdaeab938c5ffb1 by Teodor Dutu:
  Fix Issue 22659 - Do not gag semantic errors from `_d_array{,set}ctor`
  
  Signed-off-by: Teodor Dutu <teodor.dutu@gmail.com>

https://github.com/dlang/dmd/pull/13555