Bug 13182 – extern(C++) classes cause crash when allocated on the stack with scope
Status
RESOLVED
Resolution
FIXED
Severity
blocker
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2014-07-22T08:48:00Z
Last change time
2014-08-22T08:04:51Z
Keywords
pull, wrong-code
Assigned to
yebblies
Creator
yebblies
Comments
Comment #0 by yebblies — 2014-07-22T08:48:30Z
extern(C++)
class C
{
}
void main()
{
scope C c = new C();
}
This crashes because dmd inserts 'delete c;' for the scope variable and delete assumes that classinfo.
As destructors are not currently supported for C++ classes, it should not call delete at all.
Comment #2 by bearophile_hugs — 2014-07-22T08:53:18Z
(In reply to yebblies from comment #0)
> void main()
> {
> scope C c = new C();
> }
Isn't that usage of scope deprecated? And isn't it better to fix language parts that are not deprecated?
Comment #3 by yebblies — 2014-07-22T08:59:03Z
(In reply to bearophile_hugs from comment #2)
> (In reply to yebblies from comment #0)
>
> > void main()
> > {
> > scope C c = new C();
> > }
>
> Isn't that usage of scope deprecated?
I don't know if it's really deprecated. I thought it was, but then Walter told me to use it. If we do get proper 'scope' in the language then this code will become perfectly safe, so...
> And isn't it better to fix language
> parts that are not deprecated?
No. It is better to fix the parts that are useful, like this is for me. I marked it as a blocker because it's currently blocking DDMD.
Comment #4 by doob — 2014-07-22T09:03:19Z
(In reply to bearophile_hugs from comment #2)
> Isn't that usage of scope deprecated? And isn't it better to fix language
> parts that are not deprecated?
No, everyone is saying that but it's not officially deprecated. No update documentation, no deprecation or warning messages.
Comment #5 by bearophile_hugs — 2014-07-22T09:25:35Z
(In reply to yebblies from comment #3)
> I don't know if it's really deprecated. I thought it was, but then Walter
> told me to use it.
Then it's in a grey area, like several other things in D.
> If we do get proper 'scope' in the language then this
> code will become perfectly safe, so...
I agree.
Comment #6 by yebblies — 2014-07-22T10:34:52Z
(In reply to Jacob Carlborg from comment #4)
>
> No, everyone is saying that but it's not officially deprecated. No update
> documentation, no deprecation or warning messages.
Actually it _is_ listed on the deprecated features page.
I can guarantee that while it is still useful to ddmd it will not be removed from the language.
Comment #7 by doob — 2014-07-22T13:24:33Z
(In reply to yebblies from comment #6)
> Actually it _is_ listed on the deprecated features page.
Aha, I didn't even know there was a deprecated features page.
Comment #8 by github-bugzilla — 2014-07-23T07:49:23Z