-
-
Notifications
You must be signed in to change notification settings - Fork 271
Open
Description
Code to reproduce
file: test1.d
extern(C) __gshared bool test = true;
void main() {}file: test2.d
module test2;
import ldc.attributes : weak;
extern(C) __gshared @weak bool test = false;
pragma(msg, __traits(getAttributes, test)); // this triggers the errorcommand:
ldc2 -c test2.d && ldc2 test1.d test2.o
result
AliasSeq!(_weak())
/usr/bin/ld: test2.o:(.bss.test+0x0): multiple definition of `test'; test1.o:(.data.test+0x0): first defined here
collect2: error: ld returned 1 exit status
Observation
ldc defines most udas in arguments.d like this:
immutable weak = _weak();
private struct _weak {}ldc/runtime/druntime/src/ldc/attributes.d
Line 424 in 3883e04
| immutable weak = _weak(); |
uda.cpp scans symbols for attributes by checking isStructLiteralExp()
Line 98 in 3883e04
| if (auto sle = attr->isStructLiteralExp()) |
but if expressionSemantic was run prior to this check, the attr expression is VarExp and the check fails.
A simple __traits(getAttributes, sym) can trigger this error.
Changing immutable to enum fixes the issue, but there is probably a reason immutable was chosen.
Metadata
Metadata
Assignees
Labels
No labels