Why was clang ++ 3.5 unable to compile this piece of code, while clang ++ 3.6 could compile it?

This piece of code cannot compile with clang ++ 3.5, but can compile with clang ++ 3.6. And I'm looking for https://llvm.org/bugs/ can't seem to find any errors about this. So why did this piece of code fail to compile in clang ++ 3.5? g ++ don't have this problem. Thank you in advance.

void F() {}

template <typename T>
class Option {
  public:

  Option(const T &) {}

  Option(T &&) {}

  template <typename U>
  Option(const U &) {}

};

class Fork {
  public:

  Fork(const Option<void (*)(void)>&) {}

};


int main() {
  Fork fork(F);
}

      

Compilation error with clang ++ 3.5

test.cpp:25:13: error: conversion from 'void ()' to 'const Option<void (*)()>' is ambiguous
  Fork fork(F);
            ^
test.cpp:7:3: note: candidate constructor
  Option(const T &) {}
  ^
test.cpp:9:3: note: candidate constructor
  Option(T &&) {}
  ^
test.cpp:12:3: note: candidate constructor [with U = void ()]
  Option(const U &) {}
  ^
1 error generated.

      

My clang ++ version

clang++ --version
Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.1.0
Thread model: posix

      

+3


source to share


1 answer


Probably the clang ++ 3.5 compiler did not recognize the constructors in Option

that matched the type void ()

. This could have been caused by const Option<void (*)()>

being ambiguous.

Another site that can help you: LLVM Open Source Lib



PS: I would like to post this as a comment, however I am not at 50 rep.

0


source







All Articles