[LLVMbugs] [Bug 22029] New: generic lambda: failed to interpret a string when the string is in a pair
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Dec 25 12:19:41 PST 2014
http://llvm.org/bugs/show_bug.cgi?id=22029
Bug ID: 22029
Summary: generic lambda: failed to interpret a string when the
string is in a pair
Product: clang
Version: unspecified
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: C++14
Assignee: unassignedclangbugs at nondot.org
Reporter: wang_feng at live.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
Example code:
template< typename ... Args >
auto list( Args ... args )
{
return [=]( auto func ){ return func( args... ); };
}
template< typename List_1, typename List_2 >
auto cons( List_1 list_1, List_2 list_2 )
{
return list_1( [=]( auto ... args_1 ){ return list_2( [=]( auto ... args_2
){ return list( args_1..., args_2...); } ); } );
}
template< typename Func, typename List >
auto map( Func func, List the_list )
{
return the_list( [=]( auto ... elems ){ return list( func(elems)... ); } );
}
#include <string>
#include <utility>
#include <type_traits>
#include <iostream>
int main()
{
auto mfl = cons( cons( list( std::make_pair( std::string{"f1"}, [](int i){
return i; } ) ),
list( std::make_pair( std::string{"f2"}, []( double x, double
y){ return x*y; } ) ) ),
list( std::make_pair( std::string{"f3"}, [](std::string s){
return s+s; } ) ) );
auto pair_printer = []( auto the_pair ) { std::cout << "id:" <<
the_pair.first << "\n"; return the_pair; };
map( pair_printer, mfl );
return 0;
}
the expected output is(gcc 4.9 gives):
id:f1
id:f2
id:f3
but clang(3.4 and 3.5) gives:
id:f1
id: 4S� 4S�
id:4S��4S��4S��S���
�S��
84S��4S�
and clang 3.6 failed to link it.
An online version is here:
http://melpon.org/wandbox/permlink/6dnNByDwiAAl27as
Some discussion in stackoverflow is here:
http://stackoverflow.com/questions/27482444/strange-behaviour-of-generalized-lambda-in-c14
--
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/20141225/f5fc2ef7/attachment.html>
More information about the llvm-bugs
mailing list