[LLVMbugs] [Bug 16279] New: Deduction succeeds despite type mismatch of non-type template parameter and deduced argument
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sat Jun 8 15:36:02 PDT 2013
http://llvm.org/bugs/show_bug.cgi?id=16279
Bug ID: 16279
Summary: Deduction succeeds despite type mismatch of non-type
template parameter and deduced argument
Product: clang
Version: 3.2
Hardware: PC
OS: other
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: hstong at ca.ibm.com
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
clang++ does not consistently fail deduction for type mismatch of a non-type
template parameter and the corresponding deduced argument.
See N3690 subclause 14.8.2.5 [temp.deduct.type] paragraph 17.
### STANDALONE SOURCE:
template <short, char> struct A;
int foo(void *);
template <short x> int foo(A<x, x> *ap)
// neither clang++ nor g++ bother to look at the second instance of x
// for deduction
{ return noGood(ap); }
int bar(void *);
template <char y> int bar(A<y, y> *ap)
// okay; clang++ and g++ both realize that deducing from the first instance
// of y is no good
{ return noGood(ap); }
int zip(void *, void *);
template <short x, char y> int zip(A<x, y> *ap, A<y, x> *)
// clang++ does not bother to look at the second function argument
// for deduction, g++ does
{ return noGood(ap); }
A<0, 0> *ap = 0;
int a = foo(ap); // clang++ and g++ both fail to fail the argument deduction
int b = bar(ap); // clang++ and g++ both successfully fail the deduction
int c = zip(ap, ap); //
// clang++ fails to fail and g++ successfully fails the argument deduction
// For all three:
// - MSVC 17.00.51025 fails to fail the argument deduction
// - ICC 13.0.1 20121010 and IBM XL C/C++ for AIX 12.1.0.3 work fine
### COMPILER INVOCATION:
clang++ -std=c++11 -c main.cpp
### EXPECTED OUTPUT:
Successful compile.
### ACTUAL OUTPUT:
main.cpp:7:10: error: use of undeclared identifier 'noGood'
{ return noGood(ap); }
^
main.cpp:23:9: note: in instantiation of function template specialization
'foo<0>' requested here
int a = foo(ap); // clang++ and g++ both fail to fail the argument deduction
^
main.cpp:19:10: error: use of undeclared identifier 'noGood'
{ return noGood(ap); }
^
main.cpp:25:9: note: in instantiation of function template specialization
'zip<0, '\x00'>' requested here
int c = zip(ap, ap); //
^
2 errors generated.
### clang++ -v OUTPUT:
clang version 3.2 (trunk 158227)
Target: i386-pc-cygwin
Thread model: posix
--
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/20130608/a06af410/attachment.html>
More information about the llvm-bugs
mailing list