[EMAIL PROTECTED] (Joseph S. Myers)  wrote on 16.09.05 in <[EMAIL PROTECTED]>:

> C++ requires (A) and provides examples of valid programs where it can be
> told whether a normalisation of UCNs is part of the implementation-defined
> phase 1 transformation.  As I gave in a previous discussion,
>
> #include <stdlib.h>
> #include <string.h>
> #define h(s) #s
> #define str(s) h(s)
> int
> main()
> {
>   if (strcmp(str(str(\u00c1)), "\"\\u00c1\"")) abort ();
>   if (strcmp(str(str(\u00C1)), "\"\\u00C1\"")) abort ();
> }

Incidentally, gcc 3.3.5 passes this test.

However, I'm far from convinced that this is reasonable for a compiler  
supporting UCNs. It seems to me they really ought to be handled more like  
trigraphs, so that this would be

  if (strcmp(str(str(\u00C1)), "\"\u00C1\"")) abort ();

(note one less backslash), and the case of the C would be irrelevant - in  
fact, *anything* that makes it relevant feels like a bug to me.

I think comparing \u00C1 to \xC1 is a false friend here - \xC1 is only  
valid inside a string. Instead look at identifiers.

If str(str(ab\00C1cd)) == "\"ab\\00C1cd\"", then I'll certainly be  
unpleasantly surprised - that is almost certainly not what I wanted.

MfG Kai

Reply via email to