On Tue, Aug 30, 2022 at 11:18:20PM +0200, Jakub Jelinek via Gcc-patches wrote:
> On Tue, Aug 30, 2022 at 09:10:37PM +0000, Joseph Myers wrote:
> > I'm seeing build failures of glibc for powerpc64, as illustrated by the 
> > following C code:
> > 
> > #if 0
> > \NARG
> > #endif
> > 
> > (the actual sysdeps/powerpc/powerpc64/sysdep.h code is inside #ifdef 
> > __ASSEMBLER__).
> > 
> > This shows some problems with this feature - and with delimited escape 
> > sequences - as it affects C.  It's fine to accept it as an extension 
> > inside string and character literals, because \N or \u{...} would be 
> > invalid in the absence of the feature (i.e. the syntax for such literals 
> > fails to match, meaning that the rule about undefined behavior for a 
> > single ' or " as a pp-token applies).  But outside string and character 
> > literals, the usual lexing rules apply, the \ is a pp-token on its own and 
> > the code is valid at the preprocessing level, and with expansion of macros 
> > appearing before or after the \ (e.g. u defined as a macro in the \u{...} 
> > case) it may be valid code at the language level as well.  I don't know 
> > what older C++ versions say about this, but for C this means e.g.
> > 
> > #define z(x) 0
> > #define a z(
> > int x = a\NARG);
> > 
> > needs to be accepted as expanding to "int x = 0;", not interpreted as 
> > using the \N feature in an identifier and produce an error.
> 
> Thanks, will look at it tomorrow.

If
#define z(x) 0
#define a z(
int x = a\NARG);
is valid in C and C++ <= 20 then
#define z(x) 0
#define a z(
int x = a\N{LATIN SMALL LETTER A WITH ACUTE});
is too and shall preprocess to int x = 0; too.
Which would likely mean that we want to only handle it in identifiers if
in C++23 and not actually treat it as an extension except in literals.

Jason, your toughts about that?

        Jakub

Reply via email to