[Dlang-internal] UDA segfaults compiler

Basile B. b2.temp at gmx.com
Sun Jul 18 17:37:52 UTC 2021


On Saturday, 17 July 2021 at 16:33:54 UTC, Elmar wrote:
> Hello D people,
>
> I found a segmentation fault which I can reproduce with `dmd` 
> and `ldc2`.
>
> The attack code is simple:
>
> ```
> alias getOne = @(0) function int () => 1;
> ```
>
> It works without the UDA but segfaults with it. I found it 
> because I wanted to have user-defined attributes to the return 
> values of functions. I can't put the UDA after `function` so I 
> put it before.
>
> I believe, this is a forgotton corner case or something because 
> the compiler tells me, UDAs are not allowed in alias 
> definitions.

This is an assertion failure in the parser, [reported 
here](https://issues.dlang.org/show_bug.cgi?id=22127).

The code you write should not compile because the FunctionLiteral 
rule does not include the UserDefinedAttributes one.





More information about the Dlang-internal mailing list