[Issue 18338] New: typeid expression causes typeInfo to be duplicated
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jan 30 19:55:53 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=18338
Issue ID: 18338
Summary: typeid expression causes typeInfo to be duplicated
Product: D
Version: D2
Hardware: x86
OS: Windows
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: code at benjamin-thaut.de
Created attachment 1678
--> https://issues.dlang.org/attachment.cgi?id=1678&action=edit
Repro case
In the attached repro case, when compiling test.d via:
dmd -m64 test.d -c
The TypeInfo for file.DirEntry ( _D24TypeInfo_S4file8DirEntry6__initZ) will be
emitted into the object file even though its never used in test.d
This is a problem when file.d is build into a dll. Because this results in a
duplication of the type info. As a result cross dll casts and throws and all
other type info related operations may fail.
The cause is the typeid expression in file.d. As soon as the compiler
encounters a typeid expression it will instanciate the typeinfo for this type
even if the typeid expression is in a non root module. Typeid expressions
should only instanciate the type info if the typeid expression is part of a
root module.
--
More information about the Digitalmars-d-bugs
mailing list