[LLVMbugs] [Bug 20669] New: Narrowing conversion from enum to float missed: fails to cause substitution failure
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Aug 14 19:32:48 PDT 2014
http://llvm.org/bugs/show_bug.cgi?id=20669
Bug ID: 20669
Summary: Narrowing conversion from enum to float missed: fails
to cause substitution failure
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
A narrowing conversion from an unscoped enumeration to a floating-point type
does not trigger substitution failure in Clang.
The similar narrowing conversion from long long to float does.
ref: N3290 subclause 8.5.4 [dcl.init.list] paragraph 7.
### SOURCE:
$ cat narrowingEnumToFloat.cc
enum AA : long long { A = -1, B = 0x7fffffffffffffffLL } a;
template <typename T> void foo(T, char (*)[sizeof T{ a }] = 0);
int foo(int);
int main() {
return foo(0.f);
}
### COMPILER INVOCATION AND OUTPUT:
$ clang -cc1 -std=c++11 -x c++ narrowingEnumToFloat.cc
narrowingEnumToFloat.cc:7:11: error: cannot initialize return object of type
'int' with an rvalue of type 'void'
return foo(0.f);
^~~~~~~~
1 error generated.
### EXPECTED OUTPUT:
Successful compile.
### COMPILER VERSION INFO:
$ clang++ -v
clang version 3.5.0 (trunk 214060)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.2
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.0
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
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/20140815/dc43b75a/attachment.html>
More information about the llvm-bugs
mailing list