home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 32,410 of 33,346   
   Alf P. Steinbach to wolf.lammen   
   Re: header-names and universal-character   
   14 Jun 12 16:44:47   
   
   3f6f5e8c   
   From: alf.p.steinbach+usenet@gmail.com   
      
   On 11.06.2012 03:10, wolf.lammen wrote:   
   > Assume, we are on a Windows system, where a compiler may treat a   
   > backslash character in header names as a separator between path   
   > components, as it is usual on that system, and in accordance with   
   > 2.9p2.   
   >   
   > How is the source line   
   >   
   > # include "base\u0024.h"   
   >   
   > to be interpreted?   
      
   C++11 §2.3/2:   
   "Additionally, if the hexadecimal value for a universal-character-name outside   
   the c-char-sequence, s-char-sequence, or r-char-sequence of a character or   
   string literal corresponds to a control character (in either of the ranges   
   0x00–0x1F or 0x7F–0x9F,    
   both inclusive) or to a character in the basic source character set, the   
   program is ill-formed."   
      
   Then, from the grammar, the above is not a c-char, s-char or r-char-sequence,   
   but a q-char sequence:   
      
   C++11 §2.9:   
   "   
   header-name:   
      < h-char-sequence >   
      " q-char-sequence "   
   h-char-sequence:   
      h-char   
      h-char-sequence h-char   
   h-char:   
      any member of the source character set except new-line and >   
   q-char-sequence:   
      q-char   
      q-char-sequence q-char   
   q-char:   
      any member of the source character set except new-line and "   
   "   
      
   So the program would so far appear to be ill-formed, but then   
      
   C++11 §2.9/2:   
   "The appearance of either of the characters ’ or \ or of either of the   
   character sequences /* or // in a q-char-sequence or an h-char-sequence is   
   conditionally supported with implementation-defined semantics, as   
   is the appearance of the character " in an h-char-sequence."   
      
   allows the implementation to redefine the meaning of \ in this context, as   
   pointed out in the standard's note #19:   
      
   C++11 (non-normative) note #19:   
   "Thus, a sequence of characters that resembles an escape sequence might result   
   in an error, be interpreted as the character corresponding to the escape   
   sequence, or have a completely different meaning, depending on the   
   implementation."   
      
   Thus, if the implementation does not redefine the meaning of \ in the context   
   of an h-char-sequence, then the program is ill-formed by C++11 §2.3/2 (which   
   is consistent with the C++03 behavior[1]), but if it does redefine the   
   meaning, then the meaning    
   depends on the implementation by C++11 §2.9/2 (which is new wording in C++11).   
      
      
   Cheers  hth.,   
      
   - Alf   
      
   Notes:   
   [1] C++03 §2.2/2 "If the hexadecimal value for a universal character name is   
   less than 0x20 or in the range 0x7F-0x9F (inclusive), or if the universal   
   character name designates a character in the basic source character set, then   
   the program is ill-formed.   
   " and §2.8/2 "If either of the characters ’ or \, or either of the character   
   sequences /* or // appears in a q-char-sequence or a h-char-sequence, or the   
   character " appears in a h-char-sequence, the behavior is undefined"   
      
      
   --   
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca