Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 510990 (PR61144)

Summary: [4.9/bad-code] gcc miscompiles sys-libs/musl
Product: Gentoo Linux Reporter: Ryan Hill (RETIRED) <rhill>
Component: [OLD] Core systemAssignee: Gentoo Toolchain Maintainers <toolchain>
Status: RESOLVED FIXED    
Severity: normal CC: blueness, lu_zero, scjthm
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
URL: https://gcc.gnu.org/PR61144
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 915000    

Description Ryan Hill (RETIRED) gentoo-dev 2014-05-22 02:45:52 UTC
4.9.0 miscompiles fflush (possibly other functions) in musl.

Testcase:
static int dummy = 0;
extern int foo __attribute__((__weak__, __alias__("dummy")));
int bar() { if (foo) return 1; return 0; }

dirtyepic@caribou ~/tmp $ gcc-4.8.2 -O2 -c pr61144.c -o pr61144
dirtyepic@caribou ~/tmp $ objdump -dr pr61144

pr61144:     file format elf64-x86-64


Disassembly of section .text:

0000000000000000 <bar>:
   0:	8b 15 00 00 00 00    	mov    0x0(%rip),%edx        # 6 <bar+0x6>
			2: R_X86_64_PC32	foo-0x4
   6:	31 c0                	xor    %eax,%eax
   8:	85 d2                	test   %edx,%edx
   a:	0f 95 c0             	setne  %al
   d:	c3                   	retq   
dirtyepic@caribou ~/tmp $ gcc-4.9.0 -O2 -c pr61144.c -o pr61144
dirtyepic@caribou ~/tmp $ objdump -dr pr61144

pr61144:     file format elf64-x86-64


Disassembly of section .text:

0000000000000000 <bar>:
   0:	31 c0                	xor    %eax,%eax
   2:	c3                   	retq  


I'll do a backport once a patch has been approved upstream.
Comment 1 SpanKY gentoo-dev 2014-11-01 06:48:50 UTC
fix is included in gcc-4.9.2