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: unassignedclangb...@nondot.org
Reporter: abigail.buccan...@gmail.com
CC: llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs