Bug 3238 – Template function reference being made without the template body being generated

Status
RESOLVED
Resolution
WORKSFORME
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2009-08-09T20:53:00Z
Last change time
2015-06-09T01:28:08Z
Keywords
ice-on-invalid-code
Assigned to
nobody
Creator
burton-radons

Comments

Comment #0 by burton-radons — 2009-08-09T20:53:24Z
Given these two files (noting that the original file didn't have an error in it, it just allowed me to cut it down further), a.d: struct S (T) { void m () { intentional mistake; } } S! (T) f (T) () { return S! (T) (); } b.d: import a; void main () { f! (char) ().m (); } Compile them separately then link them together. The link fails because b.obj has a reference to _D1a8__T1STaZ1S1mMFZv but doesn't have a COMDAT for it (not that it could compile it).
Comment #1 by burton-radons — 2009-08-09T22:22:42Z
It turns out that there actually was a problem with the template; oddly enough the problem was one that causes the compiler to crash, unlike the banal semantic error here. So having invalid code appears to be a prerequisite for this problem to manifest.
Comment #2 by gide — 2010-05-17T19:00:18Z
Works in DMD v2.046. D:\test>dmd a.d b.d a.d(5): Error: identifier 'intentional' is not defined a.d(5): Error: intentional is used as a type a.d(9): Error: template instance a.S!(char) error instantiating b.d(5): instantiated from here: f!(char)