Cannot convert int (aka NULL) to std::vector<double*>::value_type
Tue Feb 5 04:08:00 GMT 2013

Hello All

I have a compilation error in a very large program. We have managed to
isolate the problem with the following test problem:

#include <vector>
#include <iostream>

using namespace std;

int main()
double* myPointer=NULL; // no error on this line
vector<double*> myVect(1,NULL); // error on this line
return 0;

Compiling this spits out the error:

Cannot convert 'int' to 'std::vector<double*>::value_type {aka double*}'

When I compile this on GNU gcc compiler version 4.5.1 I do not get this
error. When I compile it on GNU gcc compiler version 4.7.1 I get the

Note that this error occurs on a colleagues computer that I do not have
access to so I cannot give the exact source code and the exact error and
all the other details.

Since the first reference to NULL works then we can conclude that NULL is
defined and it can be used to initialize pointers. However when NULL is
passed as an initialization to a std::vector container it is no longer
type compatible.

Is this a bug in the 4.7.1 compiler or did the compiler change to conform
to some standard that does not allow vector's to initialized to NULL.

I just want to check with you all before I submit it as a bug. Any
comments would be much appreciated!


More information about the Gcc-help mailing list