This is the mail archive of the gcc-patches@gcc.gnu.org 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]

Re: warning: trigraph ... ignored


Thorsten Kranzkowski <th@Marvin.DL8BCU.ampr.org> writes:

> /usr/src/linux-2.4.0-test1-ac18-work/include/linux/delay.h:19:44: warning: trigraph ??/ ignored
> 
> The relevant part of delay.h (linenumbers added):
> 
> 19  * specific values can be defined in asm-???/delay.h as an override.
> 
> I don't exactly know what trigraphs are, I assume some weird replacement
> expression for unusual characters. But I don't think gcc should warn about 
> them in _comments_ !

The Standard says that it must. The relevant phases of compilation are
(paraphrasing from the Standard, not quoting):

1. Do character set conversions; replace trigraph sequences by
   their corresponding single-character representations.

2. Elide backslash-newline sequences.

3. [do stuff including replacing comments with whitespace]


Trigraphs are a horrible kludge to let people with sadly deprived
keyboards still type C code. They cause sequences of characters
beginning ?? to be replaced by a single character, like so:

              From     To
:              ??=     #
:              ??(     [
:              ??/     \
:              ??)     ]
:              ??'     ^
:              ??<     {
:              ??!     |
:              ??>     }
:              ??-     ~

So that character sequence above

: asm-???/delay.h

expands to

: asm-?\delay.h

This, in particular, is harmless. The problem is that ??/ can expand to
\, and \-newline sequences can separate the parts of a */ that closes a
comment. Thus,

/* This is a valid comment. */

/* And so is this. *\
/

/* But is *this*??/
/

(Yes, it is; it expands to

/* But is *this*/

)

GCC warns about trigraphs because they're sucky, confusing,
brain-damaged, and can do unexpected things. I think warning about them
is entirely appropriate. ;)

-- 
> ... knowing the alignment of Orcs in AD&D.
Doubleword.
  --- David Jacoby and Greg Andrews in the Monastery

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