Skip to content

[REG2.065] Issue 13321 - Wrong goto skips declaration error - #3885

Merged
3 commits merged into
dlang:masterfrom
9rnsr:fix13321
Dec 6, 2014
Merged

3 commits merged into
dlang:masterfrom
9rnsr:fix13321

Conversation

@9rnsr

@9rnsr 9rnsr commented Aug 22, 2014

Copy link
Copy Markdown
Contributor

@yebblies

Copy link
Copy Markdown
Contributor

Copy from the initializer symbol for larger symbols, otherwise the literals expressed as code get excessively large.

Do you have some examples to explain what this is about?

@9rnsr

9rnsr commented Aug 22, 2014

Copy link
Copy Markdown
Contributor Author

Untested example:

struct S { int[64] data; this(int) {}}
void main() { S s = S(1); }

I just copied the part from TypeStruct::defaultInitLiteral().

@yebblies

Copy link
Copy Markdown
Contributor

Hmm, ok. I thought this would mean that the default struct init would be the backing memory for the constructor call, and therefore could be corrupted by modifications inside the constructor, but the code at e2ir.c:3394 ( visit(CallExp*) ) clears it: sle->sinit = NULL; // don't modify initializer

struct S { int[64] data = [0, 1, 2, 3, 4, 5, 6, 7]; this(int x) { data[0] = x; }}
void func(S s, S s2) { assert(s.data[0] == 1); assert(s2.data[0] == 2); }
void main() { func(S(1), S(2));  }

@WalterBright

Copy link
Copy Markdown
Member

This fix strikes me as fixing something else, not the root problem. I suggest the fix should be to not issue the error message if the variable is a compiler generated temporary, i.e. is STCtemp.

@9rnsr

9rnsr commented Aug 22, 2014

Copy link
Copy Markdown
Contributor Author

I thought same idea, but some STCtemp variables have lifetime over multiple statements. In that case skipping temporary variable initialization would cause wrong-code bug.

@WalterBright

Copy link
Copy Markdown
Member

Hmm, you're right, but such a patch would at least get us past the 2.066 regression.

@9rnsr

9rnsr commented Aug 23, 2014

Copy link
Copy Markdown
Contributor Author

I'm not sure why runnable/sdtor.d fails in Linux32 and Darwin32...

@9rnsr
9rnsr force-pushed the fix13321 branch 2 times, most recently from 25a1705 to 7eeffe7 Compare August 26, 2014 03:35
@Orvid

Orvid commented Aug 27, 2014

Copy link
Copy Markdown
Contributor

@9rnsr Could these changes have exposed a bug in the codegen? It's failing with -inline but passing with -O. It appears that it's failing with the very first test, test1, as it doesn't even print out ~S(), which it would if it had at least gotten to where it could call the destructor in it...

@9rnsr

9rnsr commented Aug 27, 2014

Copy link
Copy Markdown
Contributor Author

Maybe. But it does not reproduce in Windows platform, and I don't have OSX environment. So fixing it is very difficult to me...

@9rnsr
9rnsr force-pushed the fix13321 branch 2 times, most recently from 998b0d5 to 0121c52 Compare September 8, 2014 12:35
@9rnsr

9rnsr commented Oct 3, 2014

Copy link
Copy Markdown
Contributor Author

Since some days (weeks?) ago, this PR passes in all platforms.
@WalterBright Could you please consider to merge this PR?

@yebblies

yebblies commented Oct 3, 2014

Copy link
Copy Markdown
Contributor

Hmm, ok. I thought this would mean that the default struct init would be the backing memory for the constructor call, and therefore could be corrupted by modifications inside the constructor, but the code at e2ir.c:3394 ( visit(CallExp*) ) clears it: sle->sinit = NULL; // don't modify initializer

Do you know if the sinit stuff is actually dead code?

@9rnsr

9rnsr commented Oct 3, 2014

Copy link
Copy Markdown
Contributor Author

@yebblies In CallExp::semantic, all necessary StructLiteralExp::elemenets are correctly filled by the StructDeclaration::fill() call, so the sinit nullify in e2ir.c should would no effect.

@9rnsr

9rnsr commented Nov 20, 2014

Copy link
Copy Markdown
Contributor Author

Rebased, and ready to merge.

@9rnsr

9rnsr commented Dec 1, 2014

Copy link
Copy Markdown
Contributor Author

Ping.

@ghost

ghost commented Dec 6, 2014

Copy link
Copy Markdown

Auto-merge toggled on

@ghost

ghost commented Dec 6, 2014

Copy link
Copy Markdown

BSD failure was unrelated, automerging.

ghost pushed a commit that referenced this pull request Dec 6, 2014
[REG2.065] Issue 13321 - Wrong goto skips declaration error
@ghost
ghost merged commit 1f8174f into dlang:master Dec 6, 2014
@9rnsr
9rnsr deleted the fix13321 branch December 15, 2014 01:19
@MartinNowak

Copy link
Copy Markdown
Member

This seems to have introduced a regression.
I was able to bisect a test failure in https://github.com/higgsjs/Higgs down to this commit.
From what I debugged in Higgs this smells like a codegen bug, a string pointer that's passed from D to the JIT code is corrupted.

@MartinNowak

Copy link
Copy Markdown
Member

@MartinNowak

Copy link
Copy Markdown
Member

Can we revert the problematic commit 91e6e87 until the regression get's fixed?

@MartinNowak

Copy link
Copy Markdown
Member

@9rnsr, can you please check whether we changed anything about the initialization before calling the ctor. The struct in Higgs had a union that was only partially initialized.

@9rnsr

9rnsr commented Feb 3, 2015

Copy link
Copy Markdown
Contributor Author

@MartinNowak Maybe it's a glue layer issue, or we might need to add more information about that into front-end layer. But, I don't have enough time to find actual issue without repro case. Could you please post it in bugzilla?

@MartinNowak

Copy link
Copy Markdown
Member

@MartinNowak Maybe it's a glue layer issue, or we might need to add more information about that into front-end layer. But, I don't have enough time to find actual issue without repro case. Could you please post it in bugzilla?

I added a comment here https://issues.dlang.org/show_bug.cgi?id=13952#c4 @9rnsr.

@CyberShadow

Copy link
Copy Markdown
Member

gulugulubing pushed a commit to gulugulubing/dmd that referenced this pull request Mar 15, 2026
* [spec/expression] Add array literal heap allocation section

Also tweak `@nogc` items.

* Add 3 more cases
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Severity:Regression PRs that fix regressions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants