public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/18089] [4.0 regression] Valgrind errors in real.c
Date: Fri, 14 Jan 2005 20:36:00 -0000	[thread overview]
Message-ID: <20050114203639.23842.qmail@sourceware.org> (raw)
In-Reply-To: <20041020200011.18089.drow@gcc.gnu.org>


------- 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


  parent reply	other threads:[~2005-01-14 20:36 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-20 20:00 [Bug tree-optimization/18089] New: " drow at gcc dot gnu dot org
2004-10-20 20:01 ` [Bug tree-optimization/18089] " drow at gcc dot gnu dot org
2004-10-20 20:18 ` pinskia at gcc dot gnu dot org
2004-12-19 15:08 ` steven at gcc dot gnu dot org
2005-01-07 15:07 ` [Bug middle-end/18089] [4.0 regression] " reichelt at gcc dot gnu dot org
2005-01-08 21:06 ` reichelt at gcc dot gnu dot org
2005-01-10  9:33 ` reichelt at gcc dot gnu dot org
2005-01-14 18:35 ` jakub at gcc dot gnu dot org
2005-01-14 20:20 ` jakub at gcc dot gnu dot org
2005-01-14 20:36 ` jakub at gcc dot gnu dot org [this message]
2005-01-14 21:45 ` pinskia at gcc dot gnu dot org
2005-01-30 23:02 ` reichelt at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050114203639.23842.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).