https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128547

            Bug ID: 128547
           Summary: GCC rejects valid program when passing empty braces to
                    function template parameter with reference type
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jlame646 at gmail dot com
  Target Milestone: ---

The following program valid program(afaik) is rejected by both gcc and clang
but accepted by clang and msvc. [Demo](https://godbolt.org/z/E3j6bvKqT). 

```
template<unsigned int N = 1>
void f1(const int (&)[N]) {} 
int main()
{
      f1({}); //gcc & edg: NO while clang & msvc: Ok

}
```

GCC says:
```
<source>: In function 'int main()':
<source>:5:9: error: no matching function for call to 'f1(<brace-enclosed
initializer list>)'
    5 |       f1({}); //gcc & edg: NO while clang & msvc: Ok
      |       ~~^~~~
  • there is 1 candidate
    • candidate 1: 'template<unsigned int N> void f1(const int (&)[N])'
      <source>:2:6:
          2 | void f1(const int (&)[N]) {}
            |      ^~
      • template argument deduction/substitution failed:
Compiler returned: 1
```

Reply via email to