* Boost testcase failure
@ 2019-07-19 9:55 navya deepika Garakapati
0 siblings, 0 replies; only message in thread
From: navya deepika Garakapati @ 2019-07-19 9:55 UTC (permalink / raw)
To: gcc
Hi Devs,
consider below reduced testcase from boost lamda.
$cat result_of_tests.cpp
#include <boost/lambda/lambda.hpp>
#include <stdio.h>
template<class A, class F> typename boost::result_of<F(A)>::type apply1(F
f, A b) {
return f(b);
}
using namespace boost::lambda;
int main(int, char *[]) {
int one = 1;
int d= (apply1<int>(_1 ,one) == 1);
printf("\n%d\n",d);
return 0;
}
when compiled with optimization O2
$g++ result_of_tests.cpp -I ./boost_1_70_0 -O2
$./a.out
0
And,when we compile same testcase with O0
$g++ result_of_tests.cpp -I ./boost_1_70_0 -O0
$./a.out
1
The above testcases is demonstrated with g++ compiler but behavior is same
on clang as well.
When we replace ,
int d= (apply1<int>(_1 ,one) == 1);
with
int d= (apply1<int&>(_1 ,one) == 1);
testcase gives correct result with or without optimization.
Wanted to confirm here,is it valid testcase or compiler optimization is
screwed up?
Thanks,
Navya
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-07-19 9:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-19 9:55 Boost testcase failure navya deepika Garakapati
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).