[llvm-bugs] [Bug 33874] New: Differences in function type handling compared with gcc?

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jul 21 02:17:32 PDT 2017


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

            Bug ID: 33874
           Summary: Differences in function type handling compared with
                    gcc?
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: lebedev.ri at gmail.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

creduced testcase:

# 0 "" 3
template <class a> void b(int, a);
template <class a, class c> void b(int, a &&e, c) {
  b(0, [=] { e; });
}
void d() { b(0, d, 0); }

clang builds it just fine:
$ /usr/bin/clang++-5.0 -std=c++11 -c -Wall -Werror main.cpp 

but not gcc:
$ g++-7 -std=c++11 -c -Wall -Werror main.cpp
: In instantiation of ‘b(int, a&&, c)::<lambda()> [with a = void (&)(); c =
int]’:
:2:14:   required from ‘struct b(int, a&&, c) [with a = void (&)(); c =
int]::<lambda()>’
:2:4:   required from ‘void b(int, a&&, c) [with a = void (&)(); c = int]’
:4:21:   required from here
:2:14: error: variable ‘e’ has function type
:2:14: error: variable ‘e’ has function type
: In instantiation of ‘struct b(int, a&&, c) [with a = void (&)(); c =
int]::<lambda()>’:
:2:4:   required from ‘void b(int, a&&, c) [with a = void (&)(); c = int]’
:4:21:   required from here
:2:14: error: field ‘b(int, a&&, c) [with a = void (&)(); c =
int]::<lambda()>::<e capture>’ invalidly declared function type
:0:25: error: ‘void b(int, a) [with a = b(int, a&&, c) [with a = void (&)(); c
= int]::<lambda()>]’, declared using local type ‘b(int, a&&, c) [with a = void
(&)(); c = int]::<lambda()>’, is used but never defined [-fpermissive]


This code was creduced from google benchmark usage, close to this:

static inline void BM(benchmark::State& state, const char* s) {
  while (state.KeepRunning()) {
  }
}
const char* str = "something";
int main(int argc, char** argv) {
  benchmark::RegisterBenchmark(str, &BM, str); // <- ok
  benchmark::RegisterBenchmark(str,  BM, str); // <- bad
  benchmark::Initialize(&argc, argv);
  benchmark::RunSpecifiedBenchmarks();
}

-- 
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/20170721/f5fea136/attachment.html>


More information about the llvm-bugs mailing list