[llvm-bugs] [Bug 47383] New: Odd "argument deduction not allowed in function return type" when initializing static data member

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Sep 1 06:57:01 PDT 2020


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: unassignedclangbugs at nondot.org
          Reporter: stephan.bergmann.secondary at googlemail.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200901/e43837b7/attachment.html>


More information about the llvm-bugs mailing list