Bug 21622 – pragma(crt_constructor) accepts functions that return non-POD types

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-02-09T08:19:56Z
Last change time
2024-12-13T19:14:35Z
Keywords
accepts-invalid
Assigned to
No Owner
Creator
Walter Bright
See also
https://issues.dlang.org/show_bug.cgi?id=21620, https://issues.dlang.org/show_bug.cgi?id=21621, https://issues.dlang.org/show_bug.cgi?id=21623, https://issues.dlang.org/show_bug.cgi?id=23535
Moved to GitHub: dmd#19869 →

Comments

Comment #0 by bugzilla — 2021-02-09T08:19:56Z
Returning types with destructors or that require hidden pointers to the return type is obviously going to fail, but is accepted by the compiler. struct S { ~this(); } extern (C) pragma(crt_constructor) S foo() { return S(); } // should not compile
Comment #1 by pro.mathias.lang — 2021-02-09T09:46:19Z
Shouldn't it just return nothing ? While there's no reason to prevent returning an `int`, there's no reason to allow it, either.
Comment #2 by robert.schadek — 2024-12-13T19:14:35Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19869 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB