🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #1265

Templates, -g, and the AT&T assembler

#1265
From: Marco S Hyman
Date: Tue, 15 Dec 1992 04:02
189 lines
5565 bytes
I think I've seen this one reported before, but just in case...

g++ -v
Reading specs from /usr/local/lib/gcc-lib/i386-sysv/2.3.1/specs
gcc version 2.3.1

Generates output that as can't handle when using -g and templates.
Specifically,  sdbout generates .defs that look like:

.def	A<class B*>;	.scl	10;	.type	010;	.size	4;	.endef

The assembler does not like '<', ' ', '*', and '>'.

------------ Sample file:

template <class T>
class A {
  public:
    A( const T& t ) : _t(t) { }
  private:
    T _t;
};

class B {
  public:
    B() {
	B* tmp = this;		// can't use this in next line
	_a = new A<B*>( tmp );
    }
  private:
    A<B*>* _a;
};

void
f()
{
    B b;
}

---------- compile command

g++ -v -g -c x.c
Reading specs from /usr/local/lib/gcc-lib/i386-sysv/2.3.1/specs
gcc version 2.3.1
 /usr/local/lib/gcc-lib/i386-sysv/2.3.1/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dunix -Di386 -D__unix__ -D__i386__ -D__unix -D__i386 -g x.c /usr/tmp/cca05204.i
GNU CPP version 2.3.1 (80386, ATT syntax)
 /usr/local/lib/gcc-lib/i386-sysv/2.3.1/cc1plus /usr/tmp/cca05204.i -quiet -dumpbase x.cc -g -version -o /usr/tmp/cca05204.s
GNU C++ version 2.3.1 (80386, ATT syntax) compiled by GNU C version 2.3.1.
 as -o x.o /usr/tmp/cca05204.s
Assembler: x.c
	aline 4	: Illegal character after '<'
	aline 4	: syntax error
	aline 6	: Illegal character after '<'
	aline 6	: syntax error
	aline 7	: Illegal character after '<'
	aline 7	: syntax error
	aline 7	: Illegal character after '<'
	aline 7	: syntax error
	aline 9	: Illegal character after '<'
	aline 9	: syntax error
	aline 84	: Illegal character after '<'
	aline 84	: syntax error
	aline 94	: Illegal character after '<'
	aline 94	: syntax error
	aline 96	: Illegal character after '<'
	aline 96	: syntax error
	aline 111	: Illegal character after '<'
	aline 111	: syntax error
	aline 111	: Illegal character after '<'
	aline 111	: syntax error
/usr/local/bin/gcc: x.o: No such file or directory

Compilation exited abnormally with code 1 at Mon Dec 14 19:57:42

---------- The assembly file generated

	.file	"x.c"
gcc2_compiled.:
.text
	.def	A<class B*>;	.scl	10;	.type	010;	.size	4;	.endef
	.def	_t;	.val	0;	.scl	8;	.type	030;	.endef
	.def	.eos;	.val	4;	.scl	102;	.tag	A<class B*>;	.size	4;	.endef
	.def	A<class B*>;	.scl	13;	.tag	A<class B*>;	.size	4;	.type	010;	.endef
	.def	B;	.scl	10;	.type	010;	.size	4;	.endef
	.def	_a;	.val	0;	.scl	8;	.tag	A<class B*>;	.size	4;	.type	030;	.endef
	.def	.eos;	.val	4;	.scl	102;	.tag	B;	.size	4;	.endef
	.def	B;	.scl	13;	.tag	B;	.size	4;	.type	010;	.endef
	.def	B;	.scl	13;	.tag	B;	.size	4;	.type	010;	.endef
	.align 4
	.def	__1B;	.val	__1B;	.scl	3;	.tag	B;	.size	4;	.type	0150;	.endef
__1B:
	pushl %ebp
	movl %esp,%ebp
	subl $4,%esp
	pushl %esi
	pushl %ebx
	movl 8(%ebp),%ebx
	.ln	1
	.def	.bf;	.val	.;	.scl	101;	.line	11;	.endef
	.def	this;	.val	8;	.scl	9;	.tag	B;	.size	4;	.type	030;	.endef
	.def	this;	.val	3;	.scl	4;	.tag	B;	.size	4;	.type	030;	.endef
	.ln	2
	.def	.bb;	.val	.;	.scl	100;	.line	2;	.endef
	.def	tmp;	.val	-4;	.scl	1;	.tag	B;	.size	4;	.type	030;	.endef
	movl %ebx,-4(%ebp)
	.ln	3
	leal -4(%ebp),%eax
	pushl %eax
	pushl $4
	call __builtin_new
	addl $4,%esp
	movl %eax,%eax
	pushl %eax
	call __t1A1ZP1BRCP1B
	addl $8,%esp
	movl %eax,%eax
	movl %eax,%esi
	movl %esi,(%ebx)
	.def	.eb;	.val	.;	.scl	100;	.line	3;	.endef
.L2:
	movl %ebx,%eax
	jmp .L1
	.align 4
	jmp .L1
	.align 4
	.ln	4
.L1:
	.def	.ef;	.val	.;	.scl	101;	.line	4;	.endef
	leal -12(%ebp),%esp
	popl %ebx
	popl %esi
	leave
	ret
	.def	__1B;	.val	.;	.scl	-1;	.endef
	.def	B;	.scl	13;	.tag	B;	.size	4;	.type	010;	.endef
	.def	B;	.scl	13;	.tag	B;	.size	4;	.type	010;	.endef
	.align 4
	.def	f__Fv;	.val	f__Fv;	.scl	2;	.type	044;	.endef
.globl f__Fv
f__Fv:
	pushl %ebp
	movl %esp,%ebp
	subl $4,%esp
	.def	.bf;	.val	.;	.scl	101;	.line	21;	.endef
	.ln	2
	.def	.bb;	.val	.;	.scl	100;	.line	2;	.endef
	.def	b;	.val	-4;	.scl	1;	.tag	B;	.size	4;	.type	010;	.endef
	leal -4(%ebp),%eax
	pushl %eax
	call __1B
	addl $4,%esp
	.def	.eb;	.val	.;	.scl	100;	.line	2;	.endef
	.ln	3
.L3:
	.def	.ef;	.val	.;	.scl	101;	.line	3;	.endef
	leave
	ret
	.def	f__Fv;	.val	.;	.scl	-1;	.endef
	.align 4
	.def	__t1A1ZP1BRCP1B;	.val	__t1A1ZP1BRCP1B;	.scl	3;	.tag	A<class B*>;	.size	4;	.type	0150;	.endef
__t1A1ZP1BRCP1B:
	pushl %ebp
	movl %esp,%ebp
	movl 8(%ebp),%edx
	.ln	1
	movl 12(%ebp),%eax
	movl (%eax),%ecx
	movl %ecx,(%edx)
	.def	.bf;	.val	.;	.scl	101;	.line	4;	.endef
	.def	this;	.val	8;	.scl	9;	.tag	A<class B*>;	.size	4;	.type	030;	.endef
	.def	t;	.val	12;	.scl	9;	.tag	B;	.size	4;	.type	0130;	.endef
	.def	this;	.val	2;	.scl	4;	.tag	A<class B*>;	.size	4;	.type	030;	.endef
	.def	.bb;	.val	.;	.scl	100;	.line	1;	.endef
.L5:
	.def	.eb;	.val	.;	.scl	100;	.line	1;	.endef
	movl %edx,%eax
	jmp .L4
	.align 4
	jmp .L4
	.align 4
	.ln	1
.L4:
	.def	.ef;	.val	.;	.scl	101;	.line	1;	.endef
	leave
	ret
	.def	__t1A1ZP1BRCP1B;	.val	.;	.scl	-1;	.endef
	.def	A<class B*>;	.scl	13;	.tag	A<class B*>;	.size	4;	.type	010;	.endef

// marc
Technical Details
Message-ID: <9212150402.AA05224@dumbcat.sf.ca.us>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!dumbcat.sf.CA.US!marc

Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!dumbcat.sf.CA.US!marc
From: marc@dumbcat.sf.CA.US (Marco S Hyman)
Subject: Templates, -g, and the AT&T assembler
Message-ID: <9212150402.AA05224@dumbcat.sf.ca.us>
Sender: gnulists@ai.mit.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Tue, 15 Dec 1992 04:02:57 GMT
Approved: bug-g++@prep.ai.mit.edu
Lines: 190