Is something wrong with the compiler ?

Michael Meissner meissner at osf.org
Sun Oct 7 10:55:10 AEST 1990


In article <1990Oct6.194120.27656 at mintaka.lcs.mit.edu>
wald at theory.lcs.mit.edu (David Wald) writes:

| In article <26875 at mimsy.umd.edu> chris at mimsy.umd.edu (Chris Torek) writes:
| >In short, when the ANSI standard says that the result of an operation
| >is undefined, it means UNDEFINED.  The computer can do anything (like
| >turn into a flower)---the system does not have to do anything remotely
| >reasonable.
| 
| I'm continually amused by the examples people give for undefined and
| implementation-defined behavior.  Can we get a list together, possibly
| to be incorporated into an Emacs macro?
| 
| Examples:
| 
|   Melt your screen;
|   Call your mother;
|   Send nasty notes to your boss;
|   ...?

I tend to use delete the offending source file, after running into an
alpha version of a compiler that did that when given a certain invalid
switch.

| ``The `#pragma' command is specified in the ANSI standard to have an
| arbitrary implementation-defined effect.  In the GNU C preprocessor,
| `#pragma' first attempts to run the game `rogue';  if that fails, it
| tries to run the game `hack'; if that fails, it tries to run GNU Emacs
| displaying the Tower of Hanoi; if that fails, it reports a fatal
| error.  In any case, preprocessing does not continue.''
|        -- from the manual for the GCC preprocessor (GCC version 1.34)

Gcc now does recognize at least one pragma (#pragma once).  Here's
what's in the source, where it keeps the code around, but #if'ed out:

#if 0
/* This was a fun hack, but #pragma seems to start to be useful.
   By failing to recognize it, we pass it through unchanged to cc1.  */

/*
 * the behavior of the #pragma directive is implementation defined.
 * this implementation defines it as follows.
 */
do_pragma ()
{
  close (0);
  if (open ("/dev/tty", O_RDONLY, 0666) != 0)
    goto nope;
  close (1);
  if (open ("/dev/tty", O_WRONLY, 0666) != 1)
    goto nope;
  execl ("/usr/games/hack", "#pragma", 0);
  execl ("/usr/games/rogue", "#pragma", 0);
  execl ("/usr/new/emacs", "-f", "hanoi", "9", "-kill", 0);
  execl ("/usr/local/emacs", "-f", "hanoi", "9", "-kill", 0);
nope:
  fatal ("You are in a maze of twisty compiler features, all different");
}
#endif
--
Michael Meissner	email: meissner at osf.org		phone: 617-621-8861
Open Software Foundation, 11 Cambridge Center, Cambridge, MA, 02142

Do apple growers tell their kids money doesn't grow on bushes?



More information about the Comp.lang.c mailing list