Thread overview
[Issue 10442] RTInfo generation can fail for structs defined in imported modules
Sep 07, 2014
Kenji Hara
Dec 24, 2017
Rainer Schuetze
Jan 30, 2018
Mike Franklin
Jan 30, 2018
Rainer Schuetze
Sep 09, 2020
Dlang Bot
Dec 17, 2022
Iain Buclaw
September 07, 2014
https://issues.dlang.org/show_bug.cgi?id=10442

Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|unspecified                 |D2

--- Comment #3 from Kenji Hara <k.hara.pg@gmail.com> ---
(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

--
December 24, 2017
https://issues.dlang.org/show_bug.cgi?id=10442

--- Comment #4 from Rainer Schuetze <r.sagitario@gmx.de> ---
still happens in dmd 2.077

--
January 30, 2018
https://issues.dlang.org/show_bug.cgi?id=10442

Mike Franklin <slavo5150@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |slavo5150@yahoo.com

--- Comment #5 from Mike Franklin <slavo5150@yahoo.com> ---
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.

--
January 30, 2018
https://issues.dlang.org/show_bug.cgi?id=10442

--- Comment #6 from Rainer Schuetze <r.sagitario@gmx.de> ---
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).

--
September 09, 2020
https://issues.dlang.org/show_bug.cgi?id=10442

--- Comment #7 from Dlang Bot <dlang-bot@dlang.rocks> ---
@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

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=10442

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P2                          |P3

--