[LLVMbugs] [Bug 18792] New: Note in wrong place when using std::enable_if_t

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Feb 10 06:49:34 PST 2014


http://llvm.org/bugs/show_bug.cgi?id=18792

            Bug ID: 18792
           Summary: Note in wrong place when using std::enable_if_t
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++1y
          Assignee: unassignedclangbugs at nondot.org
          Reporter: jonathan.sauer at gmx.de
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Consider the following code (enable_if_t is part of C++1y):

template <bool>
struct enable_if { };

template <>
struct enable_if<true> { using type = void; };

template <bool C>
using enable_if_t = typename enable_if<C>::type;

template <typename T, enable_if_t<sizeof(T) == 0>* = nullptr>
//template <typename T, typename enable_if<sizeof(T) == 0>::type* = nullptr>
static void foo()
{
}

int main()
{
  foo<int>();
}


Compiled with clang r201068 this results in:

% ~/LLVM/build/Release+Asserts/bin/clang++ -std=c++11 clang.cpp
clang.cpp:18:3: error: no matching function for call to 'foo'
  foo<int>();
  ^~~~~~~~
clang.cpp:8:40: note: candidate template ignored: disabled by 'enable_if' [with
T = int]
using enable_if_t = typename enable_if<C>::type;
                                       ^
1 error generated.


While the error is correct, the note is at the wrong place. It should be at
<foo>, not <enable_if_t>, as is the case when enable_if is used directly (see
the commented line):

% ~/LLVM/build/Release+Asserts/bin/clang++ -std=c++11 clang.cpp
clang.cpp:18:3: error: no matching function for call to 'foo'
  foo<int>();
  ^~~~~~~~
clang.cpp:11:42: note: candidate template ignored: disabled by 'enable_if'
[with T = int]
template <typename T, typename enable_if<sizeof(T) == 0>::type* = nullptr>
                                         ^
1 error 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/20140210/e621e022/attachment.html>


More information about the llvm-bugs mailing list