please help me submit a bug!
Basile B.
b2.temp at gmx.com
Fri Oct 8 15:51:53 UTC 2021
On Friday, 8 October 2021 at 15:15:52 UTC, jfondren wrote:
> On Friday, 8 October 2021 at 14:42:08 UTC, Basile B. wrote:
>> On Friday, 8 October 2021 at 14:01:40 UTC, workman wrote:
>>> I can not finish the register some how.
>>>
>>> The problem is there is no easy way to find which line cause
>>> this error:
>>>
>>> Error: array literal in `@nogc` function
>>> `app.test.updateBy!("updated_at", "counter").updateBy` may
>>> cause a GC allocation
>>>
>>>
>>> This function is huge, I hope compiler can print the the
>>> lines.
>>>
>>> I test on LDC2 1.28.0-beta1
>>
>> Why do you think that there is a bug ?
>>
>> D array literals are dynamic arrays, so the GC is used.
>>
>
> ```d
> T somef(T, size_t U)(T[U] array) { return array[0]; }
> int otherf(int[] array) { return array[0]; }
>
> @nogc unittest {
> import std.array : staticArray;
>
> int[5] a1 = [1, 2, 3, 4, 5];
> auto a2 = staticArray!([1, 2, 3]);
> auto a3 = somef([0, 5, 10]);
> auto a4 = [1, 2, 3];
> enum a5 = otherf([9, 8, 7]);
> }
> ```
>
> only one of those array literals involves the GC, so it would
> be pretty annoying for the compiler to not point it out.
> However, in this example, the compiler does say which line the
> error's on. That's the number in parentheses right before
> "Error:"
>
> ```
> example.d(10): Error: array literal in `@nogc` function
> `example.__unittest_L4_C7` may cause a GC allocation
> ```
>
> To submit an issue I'd need an example of where it doesn't
> include the line number.
You've replied to the wrong person.
More information about the Digitalmars-d
mailing list