[llvm-bugs] [Bug 50634] New: Clang rejects braced-init-list as default non-type template parameter

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jun 9 01:07:22 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=50634

            Bug ID: 50634
           Summary: Clang rejects braced-init-list as default non-type
                    template parameter
           Product: clang
           Version: 12.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: pilarlatiesa at gmail.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

Clang rejects this code:

```c++
template<bool = {}>
int f() {}
```

with:
> error: expected expression

However I believe that the C++ grammar permits that.

[temp.param]:
> The syntax for template-parameters is:
> template-parameter:
> 	type-parameter
>	parameter-declaration

[dcl.fct]:

> parameter-declaration:
> 	attribute-specifier-seq_{opt} decl-specifier-seq declarator
> 	attribute-specifier-seq_{opt} decl-specifier-seq declarator = initializer-clause
> 	attribute-specifier-seq_{opt} decl-specifier-seq abstract-declarator_{opt} 
> 	attribute-specifier-seq_{opt} decl-specifier-seq abstract-declarator
_{opt} = initializer-clause

[dcl.init]:
> initializer-clause:
>	assignment-expression
>	braced-init-list

My motivating usecase is:

```c++
template<std::true_type = {}>
int f() {}
```

which is accepted by G++.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210609/2d4ea858/attachment-0001.html>


More information about the llvm-bugs mailing list