This is the mail archive of the 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]

Testcases that assume argc != 0

Two testcases added this year assume that argc != 0.  Unfortunately,
the standard specifically allows it to be zero, and MIPS libgloss
takes advantage of this.

As always there are too many options ;)  We could:

  (1) Skip the tests on targets where argc might be zero.

  (2) Change libgloss.

  (3) Pass a nonzero value in some other way that is too complicated
      for the optimisers to propagate as a constant.

  (4) Make the test pass if argc == 0.

(1) means building up a list of targets, which seems a lot of effort for
such a small thing.  I don't like (2) because I think what libgloss is
doing is sensible when no executable name or command line arguments are
available.  (The simulator could make them available through semihosting,
but they aren't necessarily available on real boards.)  (3) might perturb
the original test too much.   I suppose the same is true of any change
to the test itself, including (4), but I thought (4) was safer and was
probably the way to go.

Tested on mipsisa64-elf.  OK to install?


	* gcc.c-torture/execute/pr28289.c (main): Return zero if argc is zero.
	* gcc.c-torture/execute/20060102-1.c (main): Likewise.

Index: gcc/testsuite/gcc.c-torture/execute/pr28289.c
--- gcc/testsuite/gcc.c-torture/execute/pr28289.c	(revision 116995)
+++ gcc/testsuite/gcc.c-torture/execute/pr28289.c	(working copy)
@@ -22,7 +22,7 @@ ix86_split_ashr (int mode)
 main (int argc, char **argv)
   ix86_split_ashr (argc);
-  return 1;
+  return argc != 0;
Index: gcc/testsuite/gcc.c-torture/execute/20060102-1.c
--- gcc/testsuite/gcc.c-torture/execute/20060102-1.c	(revision 116995)
+++ gcc/testsuite/gcc.c-torture/execute/20060102-1.c	(working copy)
@@ -10,7 +10,7 @@ int main (int argc)
   /* Test that the function above returns different values for
      different signs.  */
   if (f(argc) == f(-argc))
-    abort ();
+    return argc != 0;
   return 0;

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