Bug 15422 – [REG2.066] associative array of nested struct - crash on usage
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-12-08T15:31:00Z
Last change time
2016-02-01T17:14:23Z
Keywords
pull, wrong-code
Assigned to
nobody
Creator
dfj1esp02
Comments
Comment #0 by dfj1esp02 — 2015-12-08T15:31:05Z
class App
{
this()
{
}
void crash( int val )
in
{
assert( val == 1 );
}
body
{
struct Foo
{
this( int k )
{
a = k;
}
int a;
}
Foo foo;
int[ Foo ] map;
map[ foo ] = 1; // Crash
}
}
int main()
{
App a = new App;
a.crash( 1 );
return 0;
}
Works on dmd 2.064.2
Comment #1 by gassa — 2015-12-09T12:18:19Z
Able to reproduce this on win32/win64.
Original D.learn forum thread is mentioned in URL. An extract from there:
With dmd 2.064.2, the example compiles and runs fine.
With dmd 2.065.0, it does not compile, complaining that there is no opCmp for `Foo`s.
With dmd 2.066.0, and up to the current version dmd 2.069.2, it compiles fine but crashes at runtime.
So I'd say it's a regression somewhere between 2.064 and 2.066.
(In reply to Ivan Kazmenko from comment #1)
> With dmd 2.065.0, it does not compile, complaining that there is no opCmp
> for `Foo`s.
>
> With dmd 2.066.0, and up to the current version dmd 2.069.2, it compiles
> fine but crashes at runtime.
>
> So I'd say it's a regression somewhere between 2.064 and 2.066.
The guilty commit had been introduced in 2.065, but the actual problem had been hidden until 2.066 was released, by the compiler's "no opCmp" complaint.
PR to fix the issue: https://github.com/D-Programming-Language/dmd/pull/5304