Skip to content

CWG3187 [lex.phases] Replacement of universal-character-names in translation phase three #893

@Halalaluyafail3

Description

@Halalaluyafail3

Full name of submitter (unless configured in github; will be published with the issue): Jay Ghiron

Reference (section label): [lex.phases]/1.3

Issue description:

Consider the following two macro definitions:

#define X π
#define X \u03C0

According to translation phase three, these macro definitions should be equivalent because the universal-character-name should be replaced by the character it represents (U+03C0). However, GCC and MSVC reject this and consider them to be different. Clang accepts them as the same, but does not actually treat them the same:

#include<iostream>
#define S(...)#__VA_OPT__(__VA_ARGS__)
int main(){
    #define X π
    std::cout<<S(S(X)\n);//"π"
    //if #undef is added here, all three compilers agree on these outputs
    #define X \u03C0
    std::cout<<S(S(X)\n);//"\u03C0"
}

Additionally, the current wording forbids the following:

#define Y \##u03C0
int Y;

Since there is no preprocessing token of the form \u03C0 this is invalid, even though the intent is to allow it.

Related: P2314 and P2621

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions