on-internet
← Community

GCC and EDG rejects valid program involving calling a function template with empty braces

Stack Overflow ·

The following program valid program(afaik) is rejected by both gcc and edg but accepted by clang and msvc. Demo. template<unsigned int N = 1> void f1(const int (&)[N]) {} int main() { f1({}); //gcc & edg: NO while clang & msvc: Ok } I want to know which compiler is correct here as per the c++23 standard. 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])' <so

Comments

Sign in or sign up to comment and upvote.

No comments yet.