[LLVMbugs] [Bug 23006] New: Conditional expression accepted despite ambiguous common type: derived-to-base and base-to-derived UDC
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue Mar 24 08:17:15 PDT 2015
https://llvm.org/bugs/show_bug.cgi?id=23006
Bug ID: 23006
Summary: Conditional expression accepted despite ambiguous
common type: derived-to-base and base-to-derived UDC
Product: clang
Version: trunk
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: C++11
Assignee: unassignedclangbugs at nondot.org
Reporter: hstong at ca.ibm.com
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
Conditional expressions where the second and third operands have different
types are ill-formed if conversion can be done both ways.
Clang fails to reject the conditional expression in the case below where one
conversion is derived-to-base with slicing and the other is a user-defined
conversion.
In the case below, this manifests as an error because the wrong partial
specialization is chosen.
### SOURCE (<stdin>):
struct A;
struct B {
operator A &&();
} bObj;
struct A : B { };
enum E { Gnat };
A &&fooA(E);
bool b;
template <typename T, typename U = char [sizeof 0]> struct Hack { };
template <typename T> struct Hack<T, char [sizeof ((b ? bObj : fooA(T())),
0)]>;
void bar() {
A &&t1 = bObj;
B t2 = fooA(Gnat);
Hack<E> hack;
}
### COMPILER INVOCATION:
clang++ -cc1 -std=c++11 -x c++ -
### ACTUAL OUTPUT:
<stdin>:20:12: error: implicit instantiation of undefined template 'Hack<E,
char [4]>'
Hack<E> hack;
^
<stdin>:15:30: note: template is declared here
template <typename T> struct Hack<T, char [sizeof ((b ? bObj : fooA(T())),
0)]>;
^
1 error generated.
### EXPECTED OUTPUT:
(Successful compile).
### COMPILER VERSION INFO:
clang version 3.7.0 (trunk 232951)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation:
/usr/local/gcc-4.8.2/lib/gcc/x86_64-unknown-linux-gnu/4.8.2
Selected GCC installation:
/usr/local/gcc-4.8.2/lib/gcc/x86_64-unknown-linux-gnu/4.8.2
Candidate multilib: .;@m64
Selected multilib: .;@m64
--
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/20150324/e4862a2b/attachment.html>
More information about the llvm-bugs
mailing list