Thread overview
[Issue 23637] [betterC] DMD issues GC usage error during CTFE
Jan 16, 2023
Jack Stouffer
Jan 18, 2023
RazvanN
Jan 18, 2023
Jack Stouffer
January 16, 2023
https://issues.dlang.org/show_bug.cgi?id=23637

Jack Stouffer <jack@jackstouffer.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |betterC

--- Comment #1 from Jack Stouffer <jack@jackstouffer.com> ---
I should note that this is a bug in master

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |razvan.nitu1305@gmail.com
         Resolution|---                         |INVALID

--- Comment #2 from RazvanN <razvan.nitu1305@gmail.com> ---
This is not a bug.

You are compiling with -betterC so code needs to be generated for `myToString`. That code ends up in the object file and may be linked at some point, therefore the compiler tells you that you are compiling with -betterC which means that you cannot use functions from druntime (the array concat hook).

If you template the myToString method then the code compiles successfully because the template instances do not make it to the object file.

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

--- Comment #3 from Jack Stouffer <jack@jackstouffer.com> ---
(In reply to RazvanN from comment #2)
> If you template the myToString method then the code compiles successfully because the template instances do not make it to the object file.

I'm going to open an error message bug then. There's no way a normal user is going to know this.

--