Bug 17439 – invalid instantiation of function template can be executed by taking function pointer first

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2017-05-26T14:40:42Z
Last change time
2024-12-13T18:52:19Z
Keywords
accepts-invalid
Assigned to
No Owner
Creator
ag0aep6g
Moved to GitHub: dmd#17795 →

Comments

Comment #0 by ag0aep6g — 2017-05-26T14:40:42Z
This is a spin-off from issue 17435. This code should be rejected: ---- struct S { int field; } template ft(alias a) { int f() { return a; } } void main() { /* ft!(S.field).f(); */ /* correctly rejected */ alias fa = ft!(S.field).f; /* accepted */ /* fa(); */ /* correctly rejected */ int function() fptr = &fa; /* accepted */ int i = fptr(); /* accepted */ } ---- At least one of the "accepted" lines should be rejected. When ft or f are marked as `static`, the instantiation of ft (the first "accepted" line) gets rejected. Adding `static` like that should not have any effect. The template and the resulting function are already at module level.
Comment #1 by robert.schadek — 2024-12-13T18:52:19Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17795 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB