diff mbox

[Committed] Add a testcase for miscompile

Message ID CA+=Sn1m3b+QvELu0qP6op2KmRrtKwXNOKj7Anuk_0uD1_it0aA@mail.gmail.com
State New
Headers show

Commit Message

Andrew Pinski Nov. 7, 2014, 11:09 p.m. UTC
Hi,
  When I was developing a patch 2 years ago, I ran across us
mis-compiling libcpp/expr.c's num_equality_op.  I noticed today I
never added the testcase upstream for this mis-compiling.  I noticed
because I was porting the patch I had developed to the trunk and I had
missed the fix and I was getting a bootstrap failure but there was no
testsuite failures that was testing the problem.

Committed after a quick test to make sure the testcase is still a
valid executable testcase now.

Thanks,
Andrew Pinski

* gcc.c-torture/execute/20141107-1.c: New testcase.
diff mbox

Patch

Index: gcc.c-torture/execute/20141107-1.c
===================================================================
--- gcc.c-torture/execute/20141107-1.c	(revision 0)
+++ gcc.c-torture/execute/20141107-1.c	(revision 217242)
@@ -0,0 +1,27 @@ 
+#define bool _Bool
+
+bool f(int a, bool c) __attribute__((noinline));
+bool f(int a, bool c)
+{
+  if (!a)
+    c = !c;
+  return c;
+}
+
+void checkf(int a, bool b)
+{
+  bool c = f(a, b);
+  char d;
+  __builtin_memcpy (&d, &c, 1);
+  if ( d != (a==0)^b)
+    __builtin_abort();
+}
+
+int main(void)
+{
+  checkf(0, 0);
+  checkf(0, 1);
+  checkf(1, 1);
+  checkf(1, 0);
+  return 0;
+}
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 217241)
+++ ChangeLog	(revision 217242)
@@ -1,3 +1,7 @@ 
+2014-11-07  Andrew Pinski  <apinski@cavium.com>
+
+	* gcc.c-torture/execute/20141107-1.c: New testcase.
+
 2014-11-07  Richard Biener  <rguenther@suse.de>
 
 	PR tree-optimization/63605