llvm / llvm/llvm-project

[Clang] Accepts invalid reference declarator in type-id

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

Description

The type-id uses a nested reference declarator &(&), which forms a reference to a reference. GCC rejects it, while Clang accepts it.
Code:

```c++
using X1 = union { } & ( & ) ;
```

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

The test case was generated by a fuzzer.

Contributor guide

Open the contributing guide

Research direction

Reproduce the nested reference declarator in Clang using the provided C++ snippet, and compare its acceptance with GCC via the linked Compiler Explorer example. Trace the parser and type-id handling for `&(&)` and add a regression test showing that this invalid reference-to-reference form is rejected.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.