Bug 19735 – Error: variable extern symbols cannot have initializers
Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2019-03-13T10:46:59Z
Last change time
2019-03-15T11:52:42Z
Keywords
pull
Assigned to
No Owner
Creator
Iain Buclaw
Comments
Comment #0 by ibuclaw — 2019-03-13T10:46:59Z
Similar to issue 19734, but emphasis on the effect on user code, not the blatant implementation bug.
Given the following example:
extern
{
int f1(int a) { return a + 2; }
int f2(int a) { int b = 42; return a + b; }
}
You get the error during compilation of f2:
Error: variable `b` extern symbols cannot have initializers
As has already been established in 19734, even the parameter `a` is considered an extern symbol. However, the function `f1` compiles and a body is emitted without complaint.
Either `f1` should also be considered an error, or `f2` should be fixed to become valid code.