public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: jason@cambridge.redhat.com
To: gcc-gnats@gcc.gnu.org
Subject: middle-end/6950: gcc 3.0.4 miscompiles cppexp.c
Date: Thu, 06 Jun 2002 16:56:00 -0000	[thread overview]
Message-ID: <20020606235219.183D5F8D1D@prospero.cambridge.redhat.com> (raw)


>Number:         6950
>Category:       middle-end
>Synopsis:       gcc 3.0.4 miscompiles cppexp.c
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Thu Jun 06 16:56:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Jason Merrill
>Release:        3.0.4
>Organization:
Red Hat, Inc.
>Environment:
System: Linux prospero.cambridge.redhat.com 2.4.9-31 #1 Tue Feb 26 07:11:02 EST 2002 i686 unknown
Architecture: i686

	
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: /home/jason/eg/configure --with-gcc-version-trigger=/home/jason/eg/gcc/version.c --host=i686-pc-linux-gnu -v --with-dwarf2 --enable-threads=posix --with-as=/home/jason/s/sw/gas/as-new --with-ld=/home/jason/s/sw/ld/ld-new : (reconfigured)  : (reconfigured)  : (reconfigured)  : (reconfigured)  : (reconfigured)  : (reconfigured)  : (reconfigured)  : (reconfigured)  : (reconfigured)  : (reconfigured)  : (reconfigured)  : (reconfigured)  : (reconfigured)  : (reconfigured)  : (reconfigured)  : (reconfigured)  : (reconfigured)  : (reconfigured)  : (reconfigured)  : (reconfigured)  : (reconfigured)  : (reconfigured)  : (reconfigured)  : (reconfigured)  : (reconfigured)  : (reconfigured)  : (reconfigured)  : (reconfigured)  : (reconfigured) 
>Description:
	In Neil's recent changes to cppexp.c, num_equality_op stores the
result of a && expression into a location which is used in the expression.
gcc 3.0.4 wrongly generates code for this which first stores 0 into the
target, then computes the expression, to poor result.

	This bug is not present in 2.95.3, Red Hat 2.96-98 or 3.1.0.  I
plan to work around this bug in the trunk sources, but it might still be a
good idea to fix this in a 3.0.5 release.

>How-To-Repeat:
Here is a reduced testcase.

  typedef struct cpp_num cpp_num;
  struct cpp_num
  {
    long high;
    long low;
    char overflow;
  };

  #define num_eq(num1, num2) (num1.low == num2.low && num1.high == num2.high)

  static cpp_num
  num_equality_op (lhs, rhs)
       cpp_num lhs, rhs;
  {
    lhs.low = num_eq (lhs, rhs);
    lhs.high = 0;
    lhs.overflow = 0;
    return lhs;
  }

  int main()
  {
    cpp_num a = { 1, 2 };
    cpp_num b = { 3, 4 };

    cpp_num result = num_equality_op (a, b);
    if (result.low)
      return 1;

    result = num_equality_op (a, a);
    if (!result.low)
      return 2;

    return 0;
  }

>Fix:
	
>Release-Note:
>Audit-Trail:
>Unformatted:


             reply	other threads:[~2002-06-06 23:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-06 16:56 jason [this message]
2002-12-03 14:50 bangerth
2002-12-03 22:46 Jason Merrill
2002-12-04  6:26 bangerth

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=20020606235219.183D5F8D1D@prospero.cambridge.redhat.com \
    --to=jason@cambridge.redhat.com \
    --cc=gcc-gnats@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).