The code below has a mismatch between the function signature (String) and the actual argument passed (CString). This makes the compiler crash. Changing the signature to CString fixes it. GCC does not crash on this code (and doesn’t flag it as wrong). However, this might fall into the category “crash due to bad code”. My platform is OpenSuse 11.1 with CUDA 2.2. CUDA 2.1 didn’t have this. Can someone reproduce on a supported platform?
Here is the troublesome code:
#include <iostream>
#include <fstream>
using namespace std;
namespace Impala
{
typedef std::string String;
typedef const std::string& CString;
class Channel
{
public:
/** Constructor for the client side of the channel. */
Channel()
{
mFpInfo = 0;
}
/** Pointer to a function to be called for info messages
* in case no listener is provided.
*/
typedef void (*FP_INFO)(String msg);
private:
void
HandleInfo(CString msg)
{
if (mFpInfo)
(mFpInfo)(msg);
}
FP_INFO mFpInfo;
}; // class
} // namespace Impala
int
main(int argc, char* argv[])
{
return 0;
}
Output:
nvcc error : 'cudafe' died due to signal 11 (Invalid memory reference)
Command-line:
/usr/local/cuda/bin/nvcc --compiler-options -fno-strict-aliasing -O3 -DCUDA -I. -I/usr/local/include -I/usr/local/cuda/include -o cudaCUDA.o -c mainCuda.cu