Issue 180813
Summary Code with auto and array declarators compiles without diagnostic
Labels new issue
Assignees
Reporter vrukesh
    **What code / commands /steps will reproduce the problem?**
Compile the below sample code for standard C++17.

`
int x[5];
auto (*a)[5] = &x;
auto (&b)[5] = x;

int main() {
    return 0;
}
`

Godbolt compiler explorer link: https://godbolt.org/z/PqMrYrxvn

**What is the expected result?**
As per ISO/IEC 14882:2017 section 11.3.4 [dcl.array]

_In a declaration T D where D has the form
D1 [ constant-_expression_ ] attribute-specifier-seq
and the type of the identifier in the declaration T D1 is “derived-declarator-type-list T”, then the type of the identifier of D is an array type; if the type of the identifier of D contains the auto type-specifier, the program is ill-formed. T is called the array element type; this type shall not be a reference type, cv void, a function type or an abstract class type._

Since the code is ill-formed, there should be diagnostic error or warning.

**What happens instead?**
Compilation is successful.

Kindly check https://cplusplus.github.io/CWG/issues/2397.html
C++11 restricts the use of the auto type-specifier in an array declaration. C++23 relaxes this restriction.
This code is expected to fail compilation in C++17. This needs to be fixed.



_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to