[llvm-bugs] [Bug 47248] New: auto type of variables can not compile

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Aug 20 02:55:56 PDT 2020


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

            Bug ID: 47248
           Summary: auto type of variables can not compile
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: tangyixuan at mail.dlut.edu.cn
                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

The following code is valid in GCC, Clang rejects it:

$ cat s.C

#include <iostream>

auto add(auto a, auto b) { return a + b;}
int main()
{
  std::cout
    << add(3.5, 4) << "\n"
    << add(3, 4.5) << "\n";
}

$ clang++ -c s.C
s.C:3:10: error: 'auto' not allowed in function prototype
auto add(auto a, auto b) { return a + b;}
         ^~~~
s.C:3:18: error: 'auto' not allowed in function prototype
auto add(auto a, auto b) { return a + b;}
                 ^~~~
2 errors generated.

-- 
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/20200820/3e62e0be/attachment.html>


More information about the llvm-bugs mailing list