[llvm-bugs] [Bug 34062] New: -Wdouble-promotion false positive on C++11 brace initialization
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Aug 4 01:55:28 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=34062
Bug ID: 34062
Summary: -Wdouble-promotion false positive on C++11 brace
initialization
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: abigail.buccaneer at gmail.com
CC: llvm-bugs at lists.llvm.org
Clang's -Wdouble-promotion flags all cases where a float is implicitly
converted to a double. The conversion is lossless but often unintentional and
can be a performance issue. When the conversion is intentional, the solution
is to explicitly cast with static_cast or a C-style cast. Unfortunately, a
C++11-style brace-init of double is flagged as an implicit conversion. This
should be considered an explicit conversion for the sake of -Wdouble-promotion
as some modern C++ guidelines recommend using brace-init for casting when the
cast cannot change the value.
$ cat test.cpp
double f() { return double{1.f}; }
$ clang++-6.0 -c -std=c++2a -Wdouble-promotion -Werror test.cpp
test.cpp:1:28: error: implicit conversion increases floating-point
precision: 'float' to 'double'
[-Werror,-Wdouble-promotion]
double f() { return double{1.f}; }
~^~~
1 error generated.
$ clang++-6.0 --version | head -n 1
clang version 6.0.0-svn309896-1~exp1 (trunk)
--
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/20170804/84a2b685/attachment.html>
More information about the llvm-bugs
mailing list