From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23888 invoked by alias); 14 Jan 2005 20:36:44 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 23843 invoked by uid 48); 14 Jan 2005 20:36:39 -0000 Date: Fri, 14 Jan 2005 20:36:00 -0000 Message-ID: <20050114203639.23842.qmail@sourceware.org> From: "jakub at gcc dot gnu dot org" To: gcc-bugs@gcc.gnu.org In-Reply-To: <20041020200011.18089.drow@gcc.gnu.org> References: <20041020200011.18089.drow@gcc.gnu.org> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug middle-end/18089] [4.0 regression] Valgrind errors in real.c X-Bugzilla-Reason: CC X-SW-Source: 2005-01/txt/msg01875.txt.bz2 List-Id: ------- Additional Comments From jakub at gcc dot gnu dot org 2005-01-14 20:36 ------- To prove this is a valgrind bug and not GCC bug, I wrote a small self-contained testcase on which valgrind complains: #define EXP_BITS (32 - 5) struct real_value { unsigned int cl : 2; unsigned int sign : 1; unsigned int signalling : 1; unsigned int canonical : 1; unsigned int uexp : EXP_BITS; unsigned long sig[4]; }; #if defined __i386__ && defined USE_ASM #define REAL_EXP(REAL) \ ({ int ret; \ __asm ("movl (%%eax),%%eax; subl $0x80000000,%%eax; shrl $5, %%eax; subl $0x4000000,%%eax" \ : "=a" (ret) : "a" (REAL), "m" (*(REAL))); \ ret; }) #else #define REAL_EXP(REAL) \ ((int)((REAL)->uexp ^ (unsigned int)(1 << (EXP_BITS - 1))) \ - (1 << (EXP_BITS - 1))) #endif #if __GNUC__ >= 3 #define __noinline __attribute ((noinline)) #else #define __noinline #endif int dummy; void __noinline bar (void) { ++dummy; } void __noinline foo (struct real_value *r) { if (REAL_EXP (r) <= 5) bar (); } int main (void) { struct real_value r; r.uexp = 0x21; foo (&r); return 0; } Both with -DUSE_ASM and without CVS GCC generates the same assembly and in both cases valgrind --tool=memcheck /tmp/test fails with: ==31022== Conditional jump or move depends on uninitialised value(s) ==31022== at 0x8048368: foo (test.c:41) ==31022== by 0x80483A4: main (test.c:50) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18089