Bug 7042 – Allocation of 'creal' array with 'new' fails when linking without /noi switch
Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
tools
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2011-12-01T03:51:00Z
Last change time
2017-07-21T04:14:49Z
Assigned to
nobody
Creator
full.demon
Comments
Comment #0 by full.demon — 2011-12-01T03:51:52Z
Consider the following code:
main.d:
import std.stdio;
int main()
{
alias creal T;
writeln("alloc");
T[] x = new T[4];
writeln("done");
return 0;
}
This runs fine when compiled with:
dmd main.d
main
However, it never displays "done" (it hangs) when compiled with:
dmd -c main.d
link main.obj
main
This is the case ONLY if T is 'double', 'idouble', 'creal'. I tried all other types, but they work fine. Even a struct with one member of type double.
I use the binary package for windows of D2.056, at a Win7 32bit system. If you need more info, please ask.
Comment #2 by andrej.mitrovich — 2013-03-11T20:38:39Z
The issue is with how the linker is invoked, not with DMD itself. Reduced test-case:
void main()
{
creal[] x = new creal[4];
}
$ dmd -c test.d
OK:
$ link test.obj /noi
$ test.exe
Hangs:
$ link test.obj
$ test.exe
/noi is short for /noignorecase
Perhaps we must always use /noi, in which case this is an invalid bug report. Walter?
Comment #3 by dlang-bugzilla — 2017-07-21T04:14:49Z
(In reply to Andrej Mitrovic from comment #2)
> Perhaps we must always use /noi, in which case this is an invalid bug
> report.
It's certainly weird that the Microsoft linker defaults to case-insensitivity even though C is case-sensitive, but it's no surprise if weird bugs arise from said case-insensitivity.
In any case, I don't see why wrong link settings need to be DMD's burden. Though it's not impossible that a workaround in DMD in theory might exist, the primary cause of this problem is clearly user error.