[LLVMbugs] [Bug 14036] New: declval/decltype -- incorrect deduction of return type for std::bind
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sat Oct 6 10:58:39 PDT 2012
http://llvm.org/bugs/show_bug.cgi?id=14036
Bug #: 14036
Summary: declval/decltype -- incorrect deduction of return type
for std::bind
Product: clang
Version: trunk
Platform: Macintosh
OS/Version: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: Frontend
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: randy.thiemann at student.uhasselt.be
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
Test case:
#include <functional>
#include <type_traits>
#include <random>
typedef decltype(std::bind(
std::declval<std::uniform_int_distribution<int>>(),
std::declval<std::default_random_engine>())) func;
func randInt(int max) {
std::default_random_engine engine;
std::uniform_int_distribution<int> dist(0, max);
return std::bind(dist, engine);
}
int main() {
int i = randInt(9)();
}
Expected behaviour:
The typedef "func" matches the return type of the function randInt.
Actual behaviour:
clang does not build the test case:
test.cpp:12:12: error: no viable conversion from
'__bind<std::__1::uniform_int_distribution<int> &,
std::__1::linear_congruential_engine<unsigned int, 48271, 0, 2147483647>
&>' to 'func' (aka '__bind<std::__1::uniform_int_distribution<int>,
std::__1::linear_congruential_engine<unsigned int, 48271, 0,
2147483647>>')
return std::bind(dist, engine);
^~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/../lib/c++/v1/functional:1682:5: note: candidate constructor not
viable: no known conversion from
'__bind<std::__1::uniform_int_distribution<int> &,
std::__1::linear_congruential_engine<unsigned int, 48271, 0, 2147483647>
&>' to 'const std::__1::__bind<std::__1::uniform_int_distribution<int>,
std::__1::linear_congruential_engine<unsigned int, 48271, 0, 2147483647>>
&' for 1st argument;
__bind(const __bind& __b)
^
/usr/bin/../lib/c++/v1/functional:1695:5: note: candidate constructor not
viable: no known conversion from
'__bind<std::__1::uniform_int_distribution<int> &,
std::__1::linear_congruential_engine<unsigned int, 48271, 0, 2147483647>
&>' to 'std::__1::__bind<std::__1::uniform_int_distribution<int>,
std::__1::linear_congruential_engine<unsigned int, 48271, 0, 2147483647>>
&&' for 1st argument;
__bind(__bind&& __b)
^
1 error generated.
Extra notes:
Build tested on clang 3.1svn on OS X 10.8.2, using flags: -std=c++11
-stdlib=libc++.
Also tested on gcc 4.7.2 on OS X 10.8.2, using flags -std=c++11. It builds
using this configuration.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list