This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc 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]

Re: Results with glibc-2.2.91


This appears to be a GCC bug.  stpcpy is defined by a macro so the 
beginning of test_stpcpy looks like this:

  it = "stpcpy";
  check (((__extension__ (__builtin_constant_p ("a") ? (((size_t)(const void *)(("a") + 1) - (size_t)(const void *)("a") == 1) && strlen ("a") + 1 <= 8 ? __builtin_strcpy (one, "a") + strlen ("a") : ((char *) (__mempcpy) (one, "a", strlen ("a") + 1) - 1)) : __stpcpy (one, "a"))) - one) == 1, 1);

The code generated by gcc is this highly suspicious nonsense (-march=i586 -O2):

test_stpcpy:
	pushl	%ebp
	movl	%esp, %ebp
	pushl	%edi
	pushl	%esi
	movl	$1, %esi
	pushl	%ebx
	movl	$one, %ebx
	subl	%ebx, %esi
	subl	$20, %esp
	movl	$.LC14, it
	leal	(%ebx,%esi), %edi
	pushl	$1
	cmpl	$1, %edi
	addl	$one+2, %esi			BAD, clobbers cc
	sete	%al
	andl	$255, %eax
	pushl	%eax
	movw	$97, one
	call	check
	addl	$12, %esp


I don't know why it is doing all that silly arithmetic and comparison.
In a simple case (the expanded C above in a function alone) it justs
folds it all down to a constant 1.  But what makes it incorrect is 
scheduling the add between the cmpl and the sete.  The add insn
clobbers the condition codes.


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