TypeInfo madness
Johan Engelen via Digitalmars-d
digitalmars-d at puremagic.com
Thu Mar 24 02:37:29 PDT 2016
On Tuesday, 8 March 2016 at 21:38:58 UTC, Andrei Alexandrescu
wrote:
> On 3/7/16 1:33 PM, Yuxuan Shui wrote:
>> On Monday, 7 March 2016 at 08:49:36 UTC, Johan Engelen wrote:
>>> On Monday, 7 March 2016 at 01:47:53 UTC, Yuxuan Shui wrote:
>>>> On Sunday, 6 March 2016 at 23:27:45 UTC, Adam D. Ruppe wrote:
>>>>> It is just a mistake that TypeInfo isn't immutable, in my
>>>>> opinion.
>>>>>
>>>>> ...though changing it would be a breaking change, I think
>>>>> it would
>>>>> make sense to do it.
>>>>
>>>> Is there really anything relies on TypeInfo being mutable?
>>>
>>> LDC produces a crashing program when you change TypeInfo.name:
>>> https://github.com/ldc-developers/ldc/issues/1337
>>
>> This is because LDC put the TypeInfo struct in .rodata! Which
>> is great.
>> Further prove the point that no one is modifying TypeInfo.
>
> Great evidence. Guess we should make everything immutable then.
This code relies on it being immutable:
synchronized(typeid(Foo)) { ... }
People are using that, and their programs crash with LDC [1] [2].
For now, I think we will have to make TypeInfo mutable in LDC
[3], until there is a definite decision on this.
[1] https://github.com/ldc-developers/ldc/issues/1377
[2] https://github.com/ldc-developers/ldc/issues/1358
[3] https://github.com/ldc-developers/ldc/pull/1380
More information about the Digitalmars-d
mailing list