This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: i*86 structure assignment bug with global register vars


On Mon, 23 Oct 2000, Fergus Henderson wrote:

> gcc 2.95.2 on i*86 systems has a bug that shows up if you try to use
> structure assignment and global register variables in the same
> program.  It reports the error message "fixed or forbidden register
> ... was spilled ... This may be due to a compiler bug or to
> impossible asm statements or clauses.".

> $ cat bug.c
> 	register int reg __asm__("esi");
> 	struct s {
> 		int a;
> 		int b;
> 		long c;
> 		long d;
> 		void* e;
> 	} x, y;
> 	void foo() {
> 		x = y;
> 	}

GCC can't guarantee that it will be able to compile every program using
global register variables.  This is obvious if you consider a program
that uses up all available registers for such variables; it may be less
obvious for this example where only one register is global - but then the
x86 simply doesn't have very many registers.

To use this GCC extension reliably, you'll need to be able to tell for
certain that GCC will never need the registers you have declared global
for normal code generation.  Naturally, there's no sensible way to do
that, especially given that different versions of the compiler may work
differently in this respect; so this is simply another example of a
rather badly designed GCC extension.  Try to avoid using it.

(Our documentation should probably make this stuff clearer than it does
now.)

Bernd


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]