[gnu.gcc.bug] gcc 1.37 bug 900227_01

rfg@paris.ics.uci.edu (Ronald Guilmette) (02/28/90)

/* gcc 1.37 bug 900227_01

   gcc allows short and char type global variables to be initialized with
   addresses of relocatable entities.

   Even if the ANSI C standard seems to permit this, I believe that GCC should
   not allow it.  I tried this code on 5 different machines and it failed on
   all five (unless I also use the GNU assembler and the GNU linker).  Three
   of the five (Sun3, Sun4, and Symmetry) got link-time errors about byte
   offset overflows.  The other two (368/SystemV and AViiON) got assembly
   time errors about relocatable names used in "constant" expressions.

   It is clearly of very little value to allows this, and since mysterious
   linker or assembler errors may ensue, gcc should *not* allow it.
*/

int main ();

short s = (short) &main;
char c = (char) &main;

int main () { return 0; }