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

            Bug ID: 47383
           Summary: Odd "argument deduction not allowed in function return
                    type" when initializing static data member
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangb...@nondot.org
          Reporter: stephan.bergmann.second...@googlemail.com
                CC: htmldevelo...@gmail.com, llvm-bugs@lists.llvm.org,
                    neeil...@live.com, richard-l...@metafoo.co.uk

At least with recent Clang 12 trunk and with clang-10.0.0-2.fc32.x86_64:

> $ cat test.cc
> template<int N> struct S1 { constexpr S1(char const (&)[N]) {} };
> struct S2 { static constexpr S1 s(""); };

> $ clang++ -std=c++17 -fsyntax-only test.cc
> test.cc:2:35: error: expected parameter declarator
> struct S2 { static constexpr S1 s(""); };
>                                   ^
> test.cc:2:35: error: expected ')'
> test.cc:2:34: note: to match this '('
> struct S2 { static constexpr S1 s(""); };
>                                  ^
> test.cc:2:30: error: use of class template 'S1' requires template arguments; 
> argument deduction not allowed in function return type
> struct S2 { static constexpr S1 s(""); };
>                              ^~
> test.cc:1:24: note: template is declared here
> template<int N> struct S1 { constexpr S1(char const (&)[N]) {} };
>                        ^
> 3 errors generated.

Compilation succeeds when replacing the complete second line with either

> struct S2 { static constexpr S1 s = ""; };

or

> static constexpr S1 s("");

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to