| Issue |
179397
|
| Summary |
Can't declare an auto variable with brackets
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
aalmkainzi
|
```C
int main()
{
auto x = {0.0};
}
```
When compiled with clang 21.1.0 I get the error:
```
error: cannot use 'auto' with array in C
3 | auto ss = {0.0};
|
```
The C23 standard says:
> Type inference
> Constraints
> A declaration for which the type is inferred shall contain the storage-class specifier auto.
> Description
> For such a declaration that is the definition of an object the init-declarator shall have one of the forms
> direct-declarator = assignment-_expression_
> direct-declarator = { assignment-_expression_ }
> direct-declarator = { assignment-_expression_ , }
>
> The declared type is the type of the assignment _expression_ after lvalue, array to pointer or function
> to pointer conversion, additionally qualified by qualifiers and amended by attributes as they appear
> in the declaration specifiers, if any.
Doesn't that mean the code should work, and `x` would be a `double`?
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs