This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Patch to expose G++ builtins failures
- To: gcc-bugs at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Subject: Patch to expose G++ builtins failures
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- Date: Fri, 12 Jan 2001 17:23:41 -0500 (EST)
- Cc: mark at codesourcery dot com
This patch of testcases exposes the problems with G++ builtins I
mentioned in a previous posting.
http://gcc.gnu.org/ml/gcc-bugs/2001-01/msg00041.html
These cases all pass when compiled with gcc-2.95.2 and fail with
current CVS, so unless I'm missing something they should still work.
(E.g. I don't know if some recent namespace changes should cause these
to behave differently.
I hope these inspire someone who understands how builtins work in G++
to take a look.
Okay to install?
Thanks,
--Kaveh
2001-01-12 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* g++.old-deja/g++.other/builtins1.C: New test.
* g++.old-deja/g++.other/builtins2.C: Likewise.
* g++.old-deja/g++.other/builtins3.C: Likewise.
diff -rup orig/egcs-CVS20010111/gcc/testsuite/g++.old-deja/g++.other/builtins1.C egcs-CVS20010111/gcc/testsuite/g++.old-deja/g++.other/builtins1.C
--- orig/egcs-CVS20010111/gcc/testsuite/g++.old-deja/g++.other/builtins1.C Fri Jan 12 12:55:10 2001
+++ egcs-CVS20010111/gcc/testsuite/g++.old-deja/g++.other/builtins1.C Fri Jan 12 12:47:46 2001
@@ -0,0 +1,26 @@
+// Test whether this builtin minimally works in G++.
+// Origin: Kaveh Ghazi Jan 12, 2001
+// Copyright (C) 2001 Free Software Foundation.
+//
+// Special g++ Options: -O2
+
+extern "C" void abort (void);
+extern "C" __SIZE_TYPE__ strlen (const char *);
+
+int main ()
+{
+ if (strlen ("hello") != 5)
+ abort ();
+ if (::strlen ("hello") != 5)
+ abort ();
+ if (__builtin_strlen ("hello") != 5)
+ abort ();
+
+ return 0;
+}
+
+// Redeclaring a builtin as static is supposedly ok.
+static __SIZE_TYPE__ strlen (const char *)
+{
+ abort ();
+}
diff -rup orig/egcs-CVS20010111/gcc/testsuite/g++.old-deja/g++.other/builtins2.C egcs-CVS20010111/gcc/testsuite/g++.old-deja/g++.other/builtins2.C
--- orig/egcs-CVS20010111/gcc/testsuite/g++.old-deja/g++.other/builtins2.C Fri Jan 12 12:55:11 2001
+++ egcs-CVS20010111/gcc/testsuite/g++.old-deja/g++.other/builtins2.C Fri Jan 12 12:47:47 2001
@@ -0,0 +1,34 @@
+// Test whether this builtin minimally works in G++.
+// Origin: Kaveh Ghazi Jan 12, 2001
+// Copyright (C) 2001 Free Software Foundation.
+//
+// Special g++ Options: -O2
+
+extern "C" void abort (void);
+extern "C" char *strcpy (char *, const char *);
+extern "C" int memcmp (const void *, const void *, __SIZE_TYPE__);
+
+int main ()
+{
+ char f[16];
+
+ if (strcpy (f, "hello world") != f
+ || memcmp (f, "hello world", sizeof ("hello world")))
+ abort ();
+
+ if (::strcpy (f, "bye world") != f
+ || memcmp (f, "bye world", sizeof ("bye world")))
+ abort ();
+
+ if (__builtin_strcpy (f, "hello world") != f
+ || memcmp (f, "hello world", sizeof ("hello world")))
+ abort ();
+
+ return 0;
+}
+
+// Redeclaring a builtin as static is supposedly ok.
+static char *strcpy (char *, const char *)
+{
+ abort ();
+}
diff -rup orig/egcs-CVS20010111/gcc/testsuite/g++.old-deja/g++.other/builtins3.C egcs-CVS20010111/gcc/testsuite/g++.old-deja/g++.other/builtins3.C
--- orig/egcs-CVS20010111/gcc/testsuite/g++.old-deja/g++.other/builtins3.C Fri Jan 12 12:55:13 2001
+++ egcs-CVS20010111/gcc/testsuite/g++.old-deja/g++.other/builtins3.C Fri Jan 12 12:47:47 2001
@@ -0,0 +1,33 @@
+// Test whether this builtin minimally works in G++.
+// Origin: Kaveh Ghazi Jan 12, 2001
+// Copyright (C) 2001 Free Software Foundation.
+//
+// Special g++ Options: -O2
+
+extern "C" void abort (void);
+extern "C" void *alloca (__SIZE_TYPE__);
+
+int main ()
+{
+ void *foo;
+
+ foo = alloca (32);
+ if (!foo)
+ abort ();
+
+ foo = ::alloca (32);
+ if (!foo)
+ abort ();
+
+ foo = __builtin_alloca (32);
+ if (!foo)
+ abort ();
+
+ return 0;
+}
+
+// Redeclaring a builtin as static is supposedly ok.
+static void *alloca (__SIZE_TYPE__)
+{
+ abort ();
+}