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
ldc fails when using a struct member address in an associative array #2859
Comments
If LDC crashes (or exits unexpectedly), the most useful thing IMO is to run it with I can reproduce it; thx for the report. I'll fix it; explaining the cause would probably take as much time as fixing it. ;) |
… gagged) It was the only unguarded fatal() call in that file.
See #2860. |
Thanks for the swift response and PR ! |
… gagged) It was the only unguarded fatal() call in that file.
@LaurentTreguier note that your example triggers undefined behavior as it's prone to memory corruption - by using the
|
I'd rather argue that void main()
{
S s;
const aa = ["" : &s.a];
} |
Ah, I see. In the case I was using this, both the struct and the associative array were in the same scope, as members of a class. Using a GC-allocated struct satisfies dmd with import std.stdio;
struct S
{
string a = "a";
}
void main()
{
S* s = new S();
auto aa = ["" : &s.a];
writeln(aa);
} |
[This is the same LDC bug and has nothing to do with |
I agree in the sense that your and mine programs exibit what could be classified as a rejects-valid dmd bug, though the frontend bails out when it sees pointer to local memory escaped into a GC-allocated object as it can't prove that it's safe in the general case. In the original example the AAs were passed to another function and if that function was not a template it could store a reference to the AA or its value and pass it to another thread, without the compiler being able to see through the code. (Of course the LDC bug is unrelated to |
With the following code, LDC seems to just stop and doesn't produce any executable or object file.
I've tried this with LDC 1.8.0 on Ubuntu bash for Windows, LDC 1.11.0 and 1.12.0-beta1 on Windows 10 x64 directly; all with the same result.
Since dmd has no problem with it, I'm enclined to think this code shouldn't pose any problem.
I have no error message or backtrace, the compilation (or linking ?) silently fails with an exit code of 1.
I've tried switching the linker to ld.bfd, ld.gold and lld on Ubuntu bash, to no avail.
Where would you start to debug this ? I'm ready to try and find the cause (although I have no knowledge about compilers), especially if for some reason I'm the only one who can reproduce this.
The text was updated successfully, but these errors were encountered: