1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-10 07:55:35 +00:00

Log the bug report code into the git repo.

This commit is contained in:
Peter Boyle 2015-05-15 12:39:53 +01:00
parent f43589369a
commit 76cbcff2f1
2 changed files with 82 additions and 0 deletions

23
gcc-bug-report/README Normal file
View File

@ -0,0 +1,23 @@
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66153
Grid code breaks on GCC4.8, 4.9, 5.0 due to the
peekIndex<n> operating on lattice.
It erroneously recurses back into the Lattice<obj> variant, even though
the lattice container is dropped.
Work around is possible; if the Lattice routine is given a disambiguating
name prefix, such as
latPeekIndex<n>
GCC5 works.
However this is ugly and for now I have submitted a bug report to see the reaction and
speed of fixing.
The simple testcase in this directory is the submitted bug report that encapsulates the
problem. The test case works with icpc and with clang++, but fails consistently on g++
current variants.
Peter

59
gcc-bug-report/broken.cc Normal file
View File

@ -0,0 +1,59 @@
#include <vector>
#include <complex>
#include <type_traits>
#include <iostream>
typedef std::complex<double> ComplexD;
template <class T> class TypeMapper {
public:
enum { NestLevel = T::NestLevel };
};
template<> class TypeMapper<ComplexD> {
public:
enum { NestLevel = 0 };
};
template<class obj> class Container {
public:
std::vector<obj> data;
Container(int size) : data (size){};
};
template<class obj> class Recursive {
public:
enum { NestLevel = TypeMapper<obj>::NestLevel + 1};
obj internal;
};
template<int N,class obj,typename std::enable_if<N==obj::NestLevel >::type * = nullptr > auto function(const obj &arg)-> obj
{
std::cout<<"Leaf "<<obj::NestLevel<<std::endl;
return arg;
}
template<int N,class obj,typename std::enable_if<N!=obj::NestLevel >::type * = nullptr > auto function(const obj &arg)-> obj
{
std::cout<<"Node "<<obj::NestLevel<<std::endl;
obj ret;
ret.internal=function<N>(arg.internal);
return ret;
}
template<int N,class obj> auto function(const Container<obj> & arg)-> Container<decltype(function<N>(arg.data[0]))>
{
Container<decltype(function<N>(arg.data[0]))> ret(arg.data.size());
for(int ss=0;ss<arg.data.size();ss++){
ret.data[ss] = function<N>(arg.data[ss]);
}
return ret;
}
int main(int argc,char **argv)
{
Container<Recursive<Recursive<ComplexD> > > array(10);
Container<Recursive<Recursive<ComplexD> > > ret(10);
ret = function<1>(array);
}