dmd segmentation fault with duplicate class definition

number putimalitze at gmx.de
Thu Mar 29 20:48:47 UTC 2018


I'm learning, so no idea if this is known or what causes the 
segfault.

Linux
DMD64 D Compiler v2.078.3

```
void main()
{
	import std.stdio;
	
	{
		class C
		{
			int i;
		}
	}
	{
		class C
		{
			int i;
		}
		C c1 = new C();
		c1.i++;          // no segfault without this line
		C c2 = c1;
	}
}
```

dmd -run test.d
test.d(12): Error: declaration C is already defined in another 
scope in main
test.d(16): Error: class C no size because of forward reference
test.d(12): Error: class C is forward referenced when looking for 
'i'
test.d(12): Error: class C is forward referenced when looking for 
'i'
test.d(12): Error: class C is forward referenced when looking for 
'opDot'
test.d(12): Error: class C is forward referenced when looking for 
'opDispatch'
Segmentation fault (core dumped)




More information about the Digitalmars-d mailing list