Here is another lovely example of some code that MS vis studio compiles and runs correctly but that gcc can't compile and just chokes.


Code:
/* templated matrix class */
template<typename ftype>
class dynmatrix {
protected:
int issub ;
public:
int nrows ;
int ncols ;

/* default constructor and copy constructor and assignment operator are
all defined or overloaded */

/* copy constructor */
dynmatrix(dynmatrix &rhs)
{

/* blah blah */
}

dynmatrix &operator=(const dynmatrix &rhs)
{
/* assignment operator checks for empty left hand side and 
   generates new matrix if necessary,  otherwise copies */
}


/* construct from a file */
/* constructor that reads directly from a file */
dynmatrix(const char *fname)
{
issub = 0 ;
read(fname) ;
}

/* function template inside a templated class  avoid this unless you like using
the arcane keywords typename and template in your declarations */
/* conversion copy between float and double flat dynmatrix */
template <typename etype>
dynmatrix<etype> dcopy()
{

/* copies to a new, possibly different elementyped matrix */
}
} ;  // end dynmatrix

int main(int argc, char *argv[])
{
/* construct a float matrix and fill it with data from somewhere else (  c ) */
dynmatrix<float> dm(c) ;

/*  the next two lines compile and work in gcc,  but only because the assignment
operator can deal with the empty dd */
dynmatrix<double> dd ;
dd = dm.dcopy<double>() ;

/* the next line is supposed to create d2 via a copy constructor.  it wont compile 
with gcc.  However MS Vis studio compiles it and it works correctly */
dynmatrix<double> d2 = dm.copy<double>() ;

}
Gcc 4.3 is too stupid to find the obvious copy constructor. It gives this error:
MatrixTest.cpp:261: error: no matching function for call to â
matrix.h:1958: note: candidates are: cudamat::dynmatrix<ftype>::dynmatrix(const char*) [with ftype = double]
matrix.h:1823: note: cudamat::dynmatrix<ftype>::dynmatrix(cudamat::dynm atrix<ftype>&) [with ftype = double]

Note the highly informative inclusion of spurious characters as well. The second candidate looks like a match to me....

I grow weary of the supposedly strict standards conformant gcc. I'm not sure I much like strict C++ if it takes half a day to dig through each C++ syntax quirk.