Bug 14848 – [REG 1.012] template alias on struct field without instance requires 'this'

Status
RESOLVED
Resolution
DUPLICATE
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2015-07-29T22:59:00Z
Last change time
2016-08-28T19:15:42Z
Assigned to
nobody
Creator
remi.thebault

Comments

Comment #0 by remi.thebault — 2015-07-29T22:59:10Z
template offsetof_member(alias member) { size_t get() { return member.offsetof; } } struct S { int f } int main (string[] args) { auto i = offsetof_member!(S.f).get(); return 0; } this code triggers: Error: 'this' is only defined in non-static member functions, not main despite no instance is involved. Marking get with 'static' removes the compiler error
Comment #1 by dlang-bugzilla — 2015-09-01T06:33:32Z
This appears to be a regression, introduced in... err... DMD 1.012. Wow.
Comment #2 by andrej.mitrovich — 2016-08-28T19:15:42Z
This is a known bug *** This issue has been marked as a duplicate of issue 6842 ***