Package: gdc-4.3
Version: 1:1.046-4.3.4-5
Severity: serious

Hi,

gdc-4.3 fails to compile code with anonymous nested classes. gdc-4.1
and dmd seem to have no problems, at least not with my code.
If I try to extend Thread, I get the following compiletime-error:

cae...@snaggletux:~/D_stuff$ gdc-4.3 gdc_bug.d
gdc_bug.d: In function ‘test1’:
gdc_bug.d:26: internal compiler error: in estimate_num_insns_1, at
tree-inline.c:2494
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gdc-4.3/README.Bugs> for instructions.

With a (simple) custom class, I get the following error:

cae...@snaggletux:~/D_stuff$ gdmd-4.3 gdc_bug.d
gdc_bug.o: In function `_D7gdc_bug5test2FZv':
gdc_bug.d:(.text+0x7a): undefined reference to
`_D7gdc_bug5test2FZv12__anonclass25_ctorMFZC7gdc_bug5test2FZv12__anonclass2'
gdc_bug.o:(.data+0xc4): undefined reference to
`_D7gdc_bug5test2FZv12__anonclass25_ctorMFZC7gdc_bug5test2FZv12__anonclass2'
gdc_bug.o:(.rodata+0x60): undefined reference to
`_D7gdc_bug5test2FZv12__anonclass23barMFZi'
collect2: ld returned 1 exit status

I've attached the testing-code and the verbose output of gdmd -v.

I consider this a serious bug because anonymous nested classes are a
standard feature of D.

Cheers,
- Daniel


--- System information. ---
Architecture: i386
Kernel:       Linux 2.6.32-3-686

Debian Release: squeeze/sid
  500 testing         security.debian.org
  500 testing         ftp.de.debian.org

--- Package information. ---
Depends                         (Version) | Installed
=========================================-+-====================
gcc-4.3-base                 (>= 4.3.4-1) | 4.3.4-10
g++-4.3                      (>= 4.3.4-1) | 4.3.4-10
libphobos-4.3-dev     (= 1:1.046-4.3.4-5) | 1:1.046-4.3.4-5
libc6                            (>= 2.3) | 2.10.2-6
libgcc1                      (>= 1:4.1.1) | 1:4.4.4-1
libgmp3c2                                 | 2:4.3.2+dfsg-1
libmpfr1ldbl                              | 2.4.2-3
libstdc++6                     (>= 4.1.1) | 4.4.4-1


Package's Recommends field is empty.

Package's Suggests field is empty.
####### bug==1 - Thread ##########
cae...@snaggletux:~/D_stuff$ gdmd-4.3 -v gdc_bug.d 
parse     gdc_bug
semantic  gdc_bug
import    object        
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/object.d)
import    std.stdio     
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/stdio.d)
import    std.c.stdio   
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/c/stdio.d)
import    std.stdint    
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/stdint.d)
import    gcc.builtins  
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/gcc/builtins.d)
import    std.c.stddef  
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/c/stddef.d)
import    gcc.config.libc       
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/i486-linux-gnu/gcc/config/libc.d)
import    std.c.stdarg  
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/c/stdarg.d)
import    std.format    
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/format.d)
import    std.stdarg    
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/stdarg.d)
import    std.utf       
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/utf.d)
import    std.c.stdlib  
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/c/stdlib.d)
import    gcc.config.errno      
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/i486-linux-gnu/gcc/config/errno.d)
import    gcc.config.config     
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/i486-linux-gnu/gcc/config/config.d)
import    std.c.string  
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/c/string.d)
import    std.string    
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/string.d)
import    std.uni       
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/uni.d)
import    std.array     
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/array.d)
import    std.ctype     
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/ctype.d)
import    std.gc        
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/gc.d)
import    gcstats       
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/gcstats.d)
import    gcc.config.unix       
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/i486-linux-gnu/gcc/config/unix.d)
import    std.thread    
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/thread.d)
import    std.c.linux.linux     
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/c/linux/linux.d)
import    std.c.unix.unix       
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/c/unix/unix.d)
import    std.c.dirent  
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/c/dirent.d)
import    std.intrinsic 
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/intrinsic.d)
import    std.c.linux.linuxextern       
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/c/linux/linuxextern.d)
import    gcc.threadsem 
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/gcc/threadsem.d)
semantic2 gdc_bug
semantic3 gdc_bug
code      gdc_bug
gdc_bug.d: In function ‘test1’:
gdc_bug.d:26: internal compiler error: in estimate_num_insns_1, at 
tree-inline.c:2494
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gdc-4.3/README.Bugs> for instructions.

####### bug==2 - my own class ##########
cae...@snaggletux:~/D_stuff$ gdmd-4.3 -v gdc_bug.d 
parse     gdc_bug
semantic  gdc_bug
import    object        
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/object.d)
import    std.stdio     
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/stdio.d)
import    std.c.stdio   
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/c/stdio.d)
import    std.stdint    
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/stdint.d)
import    gcc.builtins  
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/gcc/builtins.d)
import    std.c.stddef  
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/c/stddef.d)
import    gcc.config.libc       
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/i486-linux-gnu/gcc/config/libc.d)
import    std.c.stdarg  
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/c/stdarg.d)
import    std.format    
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/format.d)
import    std.stdarg    
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/stdarg.d)
import    std.utf       
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/utf.d)
import    std.c.stdlib  
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/c/stdlib.d)
import    gcc.config.errno      
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/i486-linux-gnu/gcc/config/errno.d)
import    gcc.config.config     
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/i486-linux-gnu/gcc/config/config.d)
import    std.c.string  
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/c/string.d)
import    std.string    
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/string.d)
import    std.uni       
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/uni.d)
import    std.array     
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/array.d)
import    std.ctype     
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/ctype.d)
import    std.gc        
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/gc.d)
import    gcstats       
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/gcstats.d)
import    gcc.config.unix       
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/i486-linux-gnu/gcc/config/unix.d)
import    std.thread    
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/thread.d)
import    std.c.linux.linux     
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/c/linux/linux.d)
import    std.c.unix.unix       
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/c/unix/unix.d)
import    std.c.dirent  
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/c/dirent.d)
import    std.intrinsic 
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/intrinsic.d)
import    std.c.linux.linuxextern       
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/std/c/linux/linuxextern.d)
import    gcc.threadsem 
(/usr/lib/gcc/i486-linux-gnu/4.3.4/../../../../include/d/4.3.4/gcc/threadsem.d)
semantic2 gdc_bug
semantic3 gdc_bug
code      gdc_bug
gdc_bug.o: In function `_D7gdc_bug5test2FZv':
gdc_bug.d:(.text+0x7a): undefined reference to 
`_D7gdc_bug5test2FZv12__anonclass25_ctorMFZC7gdc_bug5test2FZv12__anonclass2'
gdc_bug.o:(.data+0xc4): undefined reference to 
`_D7gdc_bug5test2FZv12__anonclass25_ctorMFZC7gdc_bug5test2FZv12__anonclass2'
gdc_bug.o:(.rodata+0x60): undefined reference to 
`_D7gdc_bug5test2FZv12__anonclass23barMFZi'
collect2: ld returned 1 exit status
import std.stdio;
import std.thread;

const int bug = 2; // 1: Thread 2: own simple class

void main(){
	static if(bug==1)
		test1();
	static if(bug==2)
		test2();
}

static if(bug==1){
	// I cant build this test with gdc 4.3 on debian squeeze i386 (4.1 and dmd work fine)
	void test1(){
		int i=0; // this was in a loop..
		Thread t = new class Thread {
			int _i;
			this(){ _i=i; }
			int run(){
				writefln("Thread No. %s", _i);
				return 0;
			}
		};
		t.start(); 
		t.wait();
	}
}

static if(bug==2){
	class Foo {
		int x;
		this(){ x=42; }
		int bar(){
			return x;
		}
	}
	// I can't build this test with gdc 4.3 either, but there is a different error..
	void test2(){
		Foo f = new class Foo {
			int bar(){
				return 23;
			}
		};	
	}
}

Reply via email to