<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Differences in function type handling compared with gcc?"
   href="https://bugs.llvm.org/show_bug.cgi?id=33874">33874</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Differences in function type handling compared with gcc?
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>lebedev.ri@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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();
}</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>