[LLVMbugs] [Bug 18571] New: Noisy warnings about const-attributed functions used in decltype
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue Jan 21 06:28:09 PST 2014
http://llvm.org/bugs/show_bug.cgi?id=18571
Bug ID: 18571
Summary: Noisy warnings about const-attributed functions used
in decltype
Product: clang
Version: trunk
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: C++11
Assignee: unassignedclangbugs at nondot.org
Reporter: akim.demaille at gmail.com
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
It is very handy to use "decltype" to perform a snifae dispatch, as in this
example:
__attribute__((const))
bool bar()
{
return true;
}
template <typename T>
auto foo(T t) -> decltype(bar(), bool())
{
return true;
}
template <typename T>
bool foo(...)
{
return false;
}
int main()
{
return foo(23) != true;
}
Unfortunately, clang complains that the function I'm sfinaeing on, bar, is
const, and its result is ignored. The warning in itself makes sense, but not
here. In addition, it stutters.
akim at erebus /tmp $ clang++-mp-3.4 -std=c++11 sfinae.cc -Wall
sfinae.cc:8:27: warning: ignoring return value of function declared with const
attribute
[-Wunused-value]
auto foo(T t) -> decltype(bar(), bool())
^~~
sfinae.cc:8:27: warning: ignoring return value of function declared with const
attribute
[-Wunused-value]
auto foo(T t) -> decltype(bar(), bool())
^~~
2 warnings generated.
Likewise with 3.5.
$ clang++-mp-3.4 --version
clang version 3.4 (tags/RELEASE_34/final)
Target: x86_64-apple-darwin13.0.0
Thread model: posix
$ clang++-mp-3.5 --version
clang version 3.5 (trunk 198565)
Target: x86_64-apple-darwin13.0.0
Thread model: posix
Btw, I don't know if clang has something similar to gcc's
don't_ignore_the_return_value attribute, but there's probably the same issue.
--
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/20140121/a1dc1449/attachment.html>
More information about the llvm-bugs
mailing list