Bug 9161 – Linker error on linux if struct has @disabled ~this();
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
Linux
Creation time
2012-12-15T08:17:16Z
Last change time
2022-07-07T10:16:20Z
Keywords
pull
Assigned to
No Owner
Creator
Dmitry Olshansky
Comments
Comment #0 by dmitry.olsh — 2012-12-15T08:17:16Z
The intent here is to agressively prevent people from using struct that is only meant as a namespace and thus contains only static methods & opCall/opDispatch etc.
The sample below with fine on Win32 but fails to link on Linux 64-bit:
public struct dummy
{
static auto opCall(C)(in C[] name)
{
return name;
}
@disable ~this(); //comment this out to avoid error
}
void main()
{
assert(dummy("ABCDE") == "ABCDE");
}
The error message is:
test_case.o:(.data._D26TypeInfo_S9test_case5dummy6__initZ+0x58): undefined reference to `_D9test_case5dummy6__dtorMFZv'
That is the destructor symbol is not found - correct it shouldn't been there, but apparently it's referenced all the same.
Comment #1 by code — 2012-12-15T08:31:39Z
Shouldn't we just emit a null pointer into the struct TypeInfo for disabled dtors?
Comment #2 by dmitry.olsh — 2012-12-22T13:05:17Z
(In reply to comment #1)
> Shouldn't we just emit a null pointer into the struct TypeInfo for disabled
> dtors?
I do think it's the same as @disable this(); i.e. changes semantics so that you literally can't call destructor even statically. And on win32 I'm seeing just that.
Comment #3 by dlang-bot — 2022-07-07T05:05:10Z
@Geod24 updated dlang/dmd pull request #14272 "Fix 18973 - TypeInfo generation does not account for `@disable`" fixing this issue:
- Fix 9161 - Linker error if struct has disabled dtor
https://github.com/dlang/dmd/pull/14272
Comment #4 by dlang-bot — 2022-07-07T10:16:20Z
dlang/dmd pull request #14272 "Fix 18973, 9161 - TypeInfo generation does not account for `@disable`" was merged into master:
- 4df133b57411383be4721685f594ff8ab193f56d by Geod24:
Fix 9161 - Linker error if struct has disabled dtor
https://github.com/dlang/dmd/pull/14272