llvm / llvm/llvm-project

Clang incorrectly rejects identifier using UCN identifier

Open
#176,897 4 comments 0 reactions 0 assignees View on GitHub
clang:diagnostics clang:frontend diverges-from:gcc diverges-from:msvc
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

**What code / commands /steps will reproduce the problem?**

Compile the below sample code:
```cpp
int \u0D3F;

int main() {
return \U00000D3f;
}
```

Compiler Explorer link: https://godbolt.org/z/8Pbh1GGEW

What is the expected result?
Compilation should be successful.
As per the standard, identifiers may contain universal-character-names that designate characters allowed by ISO/IEC TR 10176.

What happens instead?
g++ (GCC) compilation is successful.
Clang compilation fails with:
```console
:1:5: error: expected unqualified-id
1 | int \u0D3F;
| ^
:4:12: error: expected expression
4 | return \U00000D3f;
| ^
2 errors generated.
Compiler returned: 1
```

This identifier should be accepted; Clang’s rejection appears non-conforming.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.