Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Invalid argument on implicit conversion of pointer to derived class
Invalid argument on implicit conversion of pointer to derived class [message #1849884] Mon, 07 February 2022 13:19
Liam Maps is currently offline Liam MapsFriend
Messages: 1
Registered: February 2022
Junior Member
Hi,

There's plenty of "invalid argument error" topics out there but none have so far helped me get to the bottom of the following issue. Second line of this code is marked as an error by Eclipse (underlined in red) and equipped with the following message: "Invalid arguments Candidates are: shared_ptr() shared_ptr(std::nullptr_t)"..."
LocalAPBPtr local_apb_p = boost::make_shared<LocalAPB>(sql_connection);
HolidaysPtr holidays = boost::make_shared<DBHolidays>(sql_connection); // Error: Invalid argument.

The difference is that the first line creates a shared pointer of the same type as the variable. In the second line, the created shared pointer is of a derived class.
class LocalAPB: public APB, public MsgDispatcher
{
public:
		virtual ~LocalAPB(){}
		LocalAPB(SqlDBConnectionPtr pSqlDBConnection): mpSqlDBConnection(pSqlDBConnection)
		{
				...
		};
		...
};

typedef boost::shared_ptr <LocalAPB> LocalAPBPtr;

////////////////////////////////

class Holidays
{
public:
	virtual void DefineHoliday(int Month, int Day) = 0;
	virtual void ClearHolidays(void) = 0;
	virtual bool IsHoliday(int Month, int Day) = 0;
	virtual ~Holidays(){};
};

class DBHolidays: public Holidays
{
public:
	DBHolidays(SqlDBConnectionPtr pSqlDBConnectionPtr)
	{
		...
	}
	...
};

typedef boost::shared_ptr<Holidays>HolidaysPtr;


Wherever there is such implicit conversion of a shared pointer to a base class pointer, the IDE warns of an "Invalid argument". (e.g., also in function arguments).

Turning off the warning in code analysis of course makes the errors go away.

The indexer appears to be working normally. I can Ctrl+click to get to any of the elements in those two lines. Also, the code compiles and the works just fine (I am building inside a Docker container using CDT's internal Docker container support). It's just that these errors are an eyesore and make coding and true error hunting harder.

I've tried rebuilding the indexer, made sure all that is needed is included under C/C++ General -> Preprocessor Include Paths, Macros etc., doublechecked that includes are copied in from the container to /home/user/eclipse-workspace/.metadata/.plugins/org.eclipse.cdt.docker.launcher/HEADERS/unix_var_run_docker_sock. And some more things from various online sources, which I've already forgotten.

System Info:
Eclipse IDE for C/C++ Developers (includes Incubating components)
Version: 2021-12 (4.22.0)
Build id: 20211202-1639
OS: Linux, v.5.11.0-44-generic, x86_64 / gtk 3.24.20
Java vendor: Eclipse Adoptium
Java runtime version: 17.0.1+12
Java version: 17.0.1


Any help would be greatly appreciated.
Thank you!
Previous Topic:Gets an error message that I can not really find a solution to.
Next Topic:Eclipse debug C/C++ console missing scanf input
Goto Forum:
  


Current Time: Thu Apr 25 18:09:36 GMT 2024

Powered by FUDForum. Page generated in 0.03228 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top