Bug 22622 – C file before D file on the command line causes build errors from core.stdc.stdio
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2021-12-22T21:04:40Z
Last change time
2022-03-06T14:11:14Z
Assigned to
No Owner
Creator
duser
Comments
Comment #0 by duser — 2021-12-22T21:04:40Z
---
% echo '// empty' >empty.c
% echo 'import core.stdc.stdio; void main(){}' >main.d
% dmd empty.c main.d
---
in english:
1. create an empty C file (or one with any contents that compiles)
2. create a D file that imports `core.stdc.stdio`
3. run dmd with the C file before the D file on the command line
output:
---
/opt/dmd2/linux/bin64/../../src/druntime/import/core/stdc/stdio.d(1256): Error: function `core.stdc.stdio.vfprintf` `pragma(printf)` functions must be `extern(C) int vfprintf([parameters...], const(char)*, va_list)`
/opt/dmd2/linux/bin64/../../src/druntime/import/core/stdc/stdio.d(1259): Error: function `core.stdc.stdio.vfscanf` `pragma(scanf)` functions must be `extern(C) int vfscanf([parameters...], const(char)*, va_list)`
/opt/dmd2/linux/bin64/../../src/druntime/import/core/stdc/stdio.d(1262): Error: function `core.stdc.stdio.vsprintf` `pragma(printf)` functions must be `extern(C) int vsprintf([parameters...], const(char)*, va_list)`
/opt/dmd2/linux/bin64/../../src/druntime/import/core/stdc/stdio.d(1265): Error: function `core.stdc.stdio.vsscanf` `pragma(scanf)` functions must be `extern(C) int vsscanf([parameters...], const(char)*, va_list)`
/opt/dmd2/linux/bin64/../../src/druntime/import/core/stdc/stdio.d(1268): Error: function `core.stdc.stdio.vprintf` `pragma(printf)` functions must be `extern(C) int vprintf([parameters...], const(char)*, va_list)`
/opt/dmd2/linux/bin64/../../src/druntime/import/core/stdc/stdio.d(1271): Error: function `core.stdc.stdio.vscanf` `pragma(scanf)` functions must be `extern(C) int vscanf([parameters...], const(char)*, va_list)`
/opt/dmd2/linux/bin64/../../src/druntime/import/core/stdc/stdio.d(1485): Error: function `core.stdc.stdio.vsnprintf` `pragma(printf)` functions must be `extern(C) int vsnprintf([parameters...], const(char)*, va_list)`
---
this is new in v2.098.1, it worked without errors in v2.098.0 and it affects current master (e2c591103a28ddb68d4a11de74c6ceed976e3068)
i ran "digger bisect" (good="master @ v2.098.0", bad="master") and it returned this merge commit: https://github.com/dlang/dmd/pull/13444
Comment #1 by duser — 2021-12-23T01:24:04Z
importing a C module before core.stdc.stdio also triggers the bug:
---
% echo '// empty' >empty.c
% echo 'import empty; import core.stdc.stdio; void main(){}' >main.d
% dmd main.d
---
if the import order is swapped, the error disappears