This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

macro expansion and operator &&


Hi,

I am writing code in GCC's inline assembly, and I stumbled upon what looks like a bug in GAS. It appears that when GAS expands macros, it will sometimes replace expressions with operator && by expressions with operator &, changing the original meaning of the code.

I made a tiny program to illustrate the problem. To reproduce this, run the attached program and verify that the return code is 10. The return code should actually be 0.

Is this indeed a bug?

Alex

P.S.
I'm using gas from the Ubuntu package binutils 2.19.1-0ubuntu3.
/* This program illustrates what appears to be a bug in 
 * GAS. The program should exit with error code 0, but 
 * instead it exits with error code 10. */

.section .text
	.globl _start
_start:
	/* EBX <- 0	if x == 0 and y == 0,
	 * EBX <- 10	otherwise. */
	.macro M x y
		.if \x == $0 && \y == $0
			movl $0, %ebx
		.else
			movl $10, %ebx
		.endif
	.endm
	/* Exit with return code in EBX */
	movl $1, %eax
	M $0, $0
	int $0x80

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