Thread overview
[Issue 23638] [betterC] Better Error Message For Runtime Usage
Jan 16, 2023
Jack Stouffer
Jan 18, 2023
RazvanN
Jan 18, 2023
Jack Stouffer
Jan 20, 2023
RazvanN
Jan 20, 2023
RazvanN
Feb 27, 2023
Iain Buclaw
January 16, 2023
https://issues.dlang.org/show_bug.cgi?id=23638

Jack Stouffer <jack@jackstouffer.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |betterC, diagnostic

--
January 18, 2023
https://issues.dlang.org/show_bug.cgi?id=23638

RazvanN <razvan.nitu1305@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |razvan.nitu1305@gmail.com

--- Comment #1 from RazvanN <razvan.nitu1305@gmail.com> ---
Unfortunately, the problem comes from the fact that the hook uses typeid internally. `dup` is just a normal template so the compiler does not give it any special treatment. The source of this is that dup uses internally typeid to pass a Typeinfo to the newarray hook (which currently is not templatized). Once newarray is templatized and Typeinfo is not needed anymore, the problem will disappear.

So, I guess, the real solution in this case is to templatize the _d_new_array hook.

--
January 18, 2023
https://issues.dlang.org/show_bug.cgi?id=23638

--- Comment #2 from Jack Stouffer <jack@jackstouffer.com> ---
(In reply to RazvanN from comment #1)
> Unfortunately, the problem comes from the fact that the hook uses typeid internally. `dup` is just a normal template so the compiler does not give it any special treatment. The source of this is that dup uses internally typeid to pass a Typeinfo to the newarray hook (which currently is not templatized). Once newarray is templatized and Typeinfo is not needed anymore, the problem will disappear.
> 
> So, I guess, the real solution in this case is to templatize the _d_new_array hook.

Sounds like the actual root cause is that use of typeid in betterC mode doesn't result in a trace. People have been trying to template-ize druntime for like seven years so fixing the typeid problem is more likely to bear fruit.

--
January 20, 2023
https://issues.dlang.org/show_bug.cgi?id=23638

--- Comment #3 from RazvanN <razvan.nitu1305@gmail.com> ---
(In reply to Jack Stouffer from comment #2)
> (In reply to RazvanN from comment #1)
> > Unfortunately, the problem comes from the fact that the hook uses typeid internally. `dup` is just a normal template so the compiler does not give it any special treatment. The source of this is that dup uses internally typeid to pass a Typeinfo to the newarray hook (which currently is not templatized). Once newarray is templatized and Typeinfo is not needed anymore, the problem will disappear.
> > 
> > So, I guess, the real solution in this case is to templatize the _d_new_array hook.
> 
> Sounds like the actual root cause is that use of typeid in betterC mode doesn't result in a trace. People have been trying to template-ize druntime for like seven years so fixing the typeid problem is more likely to bear fruit.

Actually, a lot of progress has been recently and a lot of hooks have already been templated: https://www.youtube.com/watch?v=dsa8GWL6TUo&ab_channel=TheDLanguageFoundation . I have highs hopes that 2023 will be the year when we finally achieve this.

--
January 20, 2023
https://issues.dlang.org/show_bug.cgi?id=23638

--- Comment #4 from RazvanN <razvan.nitu1305@gmail.com> ---
(In reply to Jack Stouffer from comment #2)
> (In reply to RazvanN from comment #1)
> > Unfortunately, the problem comes from the fact that the hook uses typeid internally. `dup` is just a normal template so the compiler does not give it any special treatment. The source of this is that dup uses internally typeid to pass a Typeinfo to the newarray hook (which currently is not templatized). Once newarray is templatized and Typeinfo is not needed anymore, the problem will disappear.
> > 
> > So, I guess, the real solution in this case is to templatize the _d_new_array hook.
> 
> Sounds like the actual root cause is that use of typeid in betterC mode doesn't result in a trace. People have been trying to template-ize druntime for like seven years so fixing the typeid problem is more likely to bear fruit.

Also, the typeid problem is just at the surface, the underlying issue is that a function that receives a Typeinfo object is called (and typeid is used to get the underling Typeinfo). We can get around this only by templating that function (which is a compiler hook).

--
February 27, 2023
https://issues.dlang.org/show_bug.cgi?id=23638

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P4

--