Bug 14404 – ClassInfo.create should forbid creating nested classes

Status
NEW
Severity
minor
Priority
P3
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-04-03T19:32:02Z
Last change time
2024-12-07T13:35:06Z
Assigned to
No Owner
Creator
matt
Moved to GitHub: dmd#17296 →

Attachments

IDFilenameSummaryContent-TypeSize
1506fail.dMinimal Code Sampletext/x-dsrc250

Comments

Comment #0 by matt — 2015-04-03T19:32:02Z
Created attachment 1506 Minimal Code Sample Calling ClassInfo.Create will fail for a class nested within a function. Minimal code to reproduce the issue follows: [CODE] extern (C) Object _d_newclass(const TypeInfo_Class ci); void main() { int kittens; class Foo { this() { kittens = 1; } ~this() { kittens = 0; } } Foo f = new Foo(); // this works typeid(f).create(); // fails } [/CODE]
Comment #1 by k.hara.pg — 2015-04-04T09:32:16Z
TypeInfo_Create.create() takes no parameter, so it cannot create nested classes with valid context pointer. Today it's filled by null, and any accesses to the enclosing context will cause Access Violation. I'm not sure what's expected 'fix' for the issue. The class Foo is declared inside main(), so constructing Foo instance by using TypeInfo_Create.create() in main() is definitely redundant. Are you requiring the create() call should throw a runtime exception for the impossible nested class construction?
Comment #2 by dlang-bugzilla — 2017-06-26T01:32:49Z
(In reply to Kenji Hara from comment #1) > Are you requiring the create() call should throw a runtime exception for the > impossible nested class construction? Updated issue title accordingly.
Comment #3 by robert.schadek — 2024-12-07T13:35:06Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17296 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB