Bug 10442 – RTInfo generation can fail for structs defined in imported modules

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-06-22T01:34:11Z
Last change time
2024-12-13T18:08:28Z
Keywords
pull, wrong-code
Assigned to
No Owner
Creator
Rainer Schuetze
Moved to GitHub: dmd#18614 →

Comments

Comment #0 by r.sagitario — 2013-06-22T01:34:11Z
The current default implementation for template RTInfo always sets the value 0x12345678, so this should work: //////////////// module s; struct S { int x; void* p; } /////////////// module test; import s; struct T { int x; void* p; } void main() { assert(typeid(T).rtInfo == cast(void*)0x12345678); // ok assert(typeid(S).rtInfo == cast(void*)0x12345678); // fails } //////////////// but the second assertion triggers if compiled with dmd test.d If you add s.d to the command line, it does not fail.
Comment #1 by r.sagitario — 2013-06-22T01:39:46Z
This is not restricted to the typeid expression, but also happens for other operations like array appending. I suspect it happens if it is only the backend that is requesting the type info, and then, AggregateDeclaration::semantic3 is never run.
Comment #2 by r.sagitario — 2013-11-30T02:01:09Z
Comment #3 by k.hara.pg — 2014-09-07T12:22:53Z
(In reply to Rainer Schuetze from comment #0) > The current default implementation for template RTInfo always sets the value > 0x12345678, so this should work: > > //////////////// > module s; > > struct S > { > int x; > void* p; > } > > /////////////// > module test; > > import s; > > struct T > { > int x; > void* p; > } > > void main() > { > assert(typeid(T).rtInfo == cast(void*)0x12345678); // ok > assert(typeid(S).rtInfo == cast(void*)0x12345678); // fails > } > > //////////////// > but the second assertion triggers if compiled with > > dmd test.d I think the typeid(S) object should not be generated when s.d is not directly compiled. IOW, `dmd test.d` should cause link failure. I implemented the behavior in: https://github.com/D-Programming-Language/dmd/pull/3958
Comment #4 by r.sagitario — 2017-12-24T09:11:11Z
still happens in dmd 2.077
Comment #5 by slavo5150 — 2018-01-30T02:34:14Z
The following example results in an assertion failure: struct T { int x; void* p; } void main() { assert(typeid(T).rtInfo == cast(void*)0x12345678); // Fail } However, the following passes: struct T { int x; void* p; } void main() { assert(typeid(T).rtInfo is null); } This is consistent with what I see in the runtime: https://github.com/dlang/druntime/blob/544946df1c68727d84cdee11502b244bde0bc22e/src/object.d#L3419 So, I don't understand what the problem is and what the result should be.
Comment #6 by r.sagitario — 2018-01-30T07:49:31Z
The definition of RTInfo(T) in object.d has changed since 2013 from 0x12345678 to null. The test in https://github.com/dlang/dmd/pull/2480 verifies that https://github.com/dlang/dmd/blob/master/src/dmd/todt.d#L1394 doesn't use the fallback if no RTInfo has been evaluated (which writes 1 if the struct contains pointers).
Comment #7 by dlang-bot — 2020-09-09T07:10:56Z
@rainers updated dlang/dmd pull request #2480 "fix issues #10442: no or incomplete RTInfo" fixing this issue: - fix issue 10442: predict type info references in glue layer - add test case for issue 10442 https://github.com/dlang/dmd/pull/2480
Comment #8 by robert.schadek — 2024-12-13T18:08:28Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18614 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB