Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REG 2.066] Issue 14838 - Wrong attribute inference for auto-generated class destructor with static array of non-POD type #4845

Merged
merged 2 commits into from
Jul 30, 2015

Conversation

9rnsr
Copy link
Contributor

@9rnsr 9rnsr commented Jul 29, 2015

https://issues.dlang.org/show_bug.cgi?id=14838

Add _ArrayPostblit and _ArrayDtor, then use them for static array copying and destruction.

"void _ArrayPostblit(T)(T[] a) { foreach (ref T e; a) e.__xpostblit(); }\n";

static const utf8_t code_ArrayDtor[] =
"void _ArrayDtor(T)(T[] a) { foreach_reverse (ref T e; a) e.__xdtor(); }\n";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have those in druntime, called _recursiveDestroy and _recursivePostblit, but it's indeed an interesting idea to move them into the compiler.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean _destructRecurse and _postblitRecurse? I also planned them, but i decided not to use them.
Because they're specialized to T[n]. It will instantiate different templates for T[1], T[2], ..., so they would cause template bloat.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, your solution is much nicer. Also we no longer need those functions in druntime, better if everything stays on one side.
dlang/druntime#1335

@MartinNowak
Copy link
Member

Mmh, seems like I shouldn't have spent my time on this (MartinNowak@3a149d2), maybe you find something interesting.

p.nextToken();
members->append(p.parseDeclDefs(0));
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does it have to be module object? How about module __internals and then parsing a single piece of code.
That way you wouldn't need to deal with conflicting symbols.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better, but this is the most easy way that I can implement quickly. This change is for the regression issue, so I should not use risky way.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A separate module might require linkage, but appending to object might also cause issues and sure is confusing. But you're right, let's do that as follow-up.

@MartinNowak
Copy link
Member

Mostly looks good, thanks a lot.
I'm a bit unsure about parsing additional object.d members. A separate module might be better.

Will continue the review this evening.

9rnsr added 2 commits July 30, 2015 00:29
By this, we can avoid the mutual dependency between compiler and druntime.
…destructor with static array of non-POD type
MartinNowak added a commit that referenced this pull request Jul 30, 2015
[REG 2.066] Issue 14838 - Wrong attribute inference for auto-generated class destructor with static array of non-POD type
@MartinNowak MartinNowak merged commit 7e53100 into dlang:stable Jul 30, 2015
* Need to add things like "const ~this()" and "immutable ~this()" to
* fix properly.
*/
e->type = e->type->mutableOf();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you are overwriting e->type. Why is that different from the case above?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because VarExp is one of the leaf AST node. Its semantic will return itself. So the type setting is low risk.

@9rnsr
Copy link
Contributor Author

9rnsr commented Jul 30, 2015

@MartinNowak Thanks!

@9rnsr 9rnsr deleted the fix14838 branch July 30, 2015 12:14
@MartinNowak
Copy link
Member

I've alreay seen a lot of error message à la object._ArrayDtor isn't nothrow.
This is somewhat misleading b/c object obviously doesn't have such a function and it's unclear who called _ArrayDtor. For the master branch we should establish an internal module, maybe we can also polish the error message to name the cause of the failure (dtor of whatever T isn't nothrow).

@MartinNowak
Copy link
Member

Ping

@9rnsr
Copy link
Contributor Author

9rnsr commented Aug 22, 2015

Internal module is not bad idea, but I'm not sure which name is the best for that module (__builtin, core.compiler, etc). Even if we reach to the best name, it's members are still invisible from dmd end users. So I'm not sure the approach will give benefits to users.

Better approach for the issue is to think about the ideal diagnostic message what you expects. Please give me some idea If you have.

@JackStouffer
Copy link
Member

This introduced a regression https://issues.dlang.org/show_bug.cgi?id=15304

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants