llvm / llvm/llvm-project

[Clang] accepts ambiguous inline namespace redeclaration

Open
#183,476 4 comments 0 reactions 0 assignees View on GitHub
accepts-invalid clang:frontend diverges-from:edg diverges-from:gcc generated by fuzzer
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

The code creates an inline namespace `::X0` containing another inline namespace `::X0::X0`. Because inline namespaces inject members into the enclosing namespace for lookup, `::X0::X0` also becomes visible as `::X0` at global scope, making the later `inline namespace X0 {}` ambiguous. GCC rejects it; Clang accepts it.

Code:
```
inline namespace X0 { inline namespace X0 { } } inline namespace X0 { }
```

See Compiler Explorer: [https://godbolt.org/z/crcEhreqP](https://godbolt.org/z/crcEhreqP)

The test case was generated by a fuzzer.

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.