This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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]

middle-end/6950: gcc 3.0.4 miscompiles cppexp.c


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


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