Fix PR35264, ntfs-3g miscompilation on i386

Michael Matz matz@suse.de
Wed Feb 20 16:43:00 GMT 2008


Hi,

Due to missing breaks in a switch statement in ix86_expand_branch, the 
testcase below (reduced from ntfs-3g) aborts.  Fixed in the obvious way.  
I'm currently regstrapping this.  Richi already pre-approved this for the 
4.3 branch, so I'm going to check this in there when regstrapping 
succeeded.


Ciao,
Michael.
-- 
        PR target/35264
        * config/i386/i386.c (ix86_expand_branch): Add missing breaks.

        * gcc.dg/pr35264.c: New testcase.

Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c	(revision 132470)
+++ config/i386/i386.c	(working copy)
@@ -12148,6 +12152,7 @@ ix86_expand_branch (enum rtx_code code, 
 		  ix86_expand_branch (code, label);
 		  return;
 		}
+	      break;
 	    case LE: case LEU: case GT: case GTU:
 	      if (lo[1] == constm1_rtx)
 		{
@@ -12156,6 +12161,7 @@ ix86_expand_branch (enum rtx_code code, 
 		  ix86_expand_branch (code, label);
 		  return;
 		}
+	      break;
 	    default:
 	      break;
 	    }
Index: testsuite/gcc.dg/pr35264.c
===================================================================
--- testsuite/gcc.dg/pr35264.c	(revision 0)
+++ testsuite/gcc.dg/pr35264.c	(revision 0)
@@ -0,0 +1,24 @@
+/* { dg-do run } */
+/* { dg-options "-O1" } */
+extern void abort(void);
+long long __attribute__((noinline)) get(void)
+{
+  return -2;
+}
+long long __attribute__((noinline)) get(void);
+int __attribute__((noinline)) check(void)
+{
+ long long lcn;
+
+ lcn = get();
+ if (lcn >= 0 || lcn == -1)
+  return 0;
+
+ return -1;
+}
+int main()
+{
+  if (check() == 0)
+    abort();
+  return 0;
+}



More information about the Gcc-patches mailing list