This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: don't assume pointer cast to unsigned long is a validinitializer
- From: Geoff Keating <geoffk at geoffk dot org>
- To: mark at codesourcery dot com
- Cc: aoliva at redhat dot com, rth at redhat dot com, gcc-patches at gcc dot gnu dot org
- Date: Mon, 3 Mar 2003 11:02:20 -0800
- Subject: Re: don't assume pointer cast to unsigned long is a validinitializer
- References: <3100000.1046652025@localhost>
OK, here's the patch I'm about to commit.
I took a partial survey, and I believe that this code should work on:
- All mips-elf platforms (due to R_MIPS_64)
- avr-elf (R_AVR_32)
- powerpc-XCOFF
- sparc-elf (R_SPARC_64)
- xstormy16-elf (R_XSTORMY16_32)
of the platforms where it's not identical to 20011114-1.c. I couldn't
find any platform where this functionality should *not* work, so
haven't added them into a .x file.
--
- Geoffrey Keating <geoffk at geoffk dot org>
===File ~/patches/apple/gcc-20010327fix.patch===============
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/ChangeLog,v
retrieving revision 1.2460
diff -u -p -u -p -r1.2460 ChangeLog
--- ChangeLog 2 Mar 2003 22:34:02 -0000 1.2460
+++ ChangeLog 3 Mar 2003 19:01:03 -0000
@@ -1,3 +1,8 @@
+2003-03-03 Geoffrey Keating <geoffk at apple dot com>
+
+ * gcc.c-torture/compile/20010327-1.c: Back out last change. Add
+ comment explaining purpose of testcase.
+
2003-03-02 Stephane Carrez <stcarrez at nerim dot fr>
* gcc.c-torture/execute/960312-1.x: New file, must pass -mshort
Index: gcc.c-torture/compile/20010327-1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.c-torture/compile/20010327-1.c,v
retrieving revision 1.4
diff -u -p -u -p -r1.4 20010327-1.c
--- gcc.c-torture/compile/20010327-1.c 28 Feb 2003 09:38:40 -0000 1.4
+++ gcc.c-torture/compile/20010327-1.c 3 Mar 2003 19:01:03 -0000
@@ -1,6 +1,9 @@
+/* This testcase tests whether GCC can produce static initialized data
+ that references addresses of size 'unsigned long', even if that's not
+ the same as __SIZE_TYPE__. (See 20011114-1.c for the same test of
+ size __SIZE_TYPE__.)
+
+ Some rare environments might not have the required relocs to support
+ this; they should have this test disabled in the .x file. */
extern void _text;
-/* We use __SIZE_TYPE__ here because it's as wide as a pointer, so we
- know we won't have a non-constant because of extension or
- truncation of the pointer to fit. */
-static __SIZE_TYPE__ x
- = (__SIZE_TYPE__) &_text - (__SIZE_TYPE__) 0x10000000L - 1;
+static unsigned long x = (unsigned long) &_text - 0x10000000L - 1;
============================================================