Question

So I mistakenly passed an int into a function parameter expecting a pointer to a const object and I got this warning from GCC:

jni/../../../Source/Controller/UserExperienceManager.cpp: In member function 'void CUserExperienceManager::SendUXPToPOS(Types::CString)':
jni/../../../Source/Controller/UserExperienceManager.cpp:243:78: warning: invalid conversion from 'int' to 'const WebService_POSAgent::CDataCheck*' [-fpermissive]
jni/../../../../../Core/WebServices/Services/POSAgent/POSAgent.h:80:18: warning:   initializing argument 2 of 'CEvent& WebService_POSAgent::CPOSAgent::AddUserExperienceID(Types::CString, const WebService_POSAgent::CDataCheck*, Types::CString)' [-fpermissive]

I tried to create a reproducible sample of this but I wasn't able to and I can't share too much of the code here. I compiled the same thing on MSVC9 and it properly gave me an error. I'm just in shock that I'm not getting an error from GCC on this! Anyone know why? Here are some simple snippets:

Function Declaration (class member function):

CEvent& AddUserExperienceID(CString userExperienceId, CDataCheck const* check, CString requestId = REQUEST_ID);

Function Call Site:

int nCheckNum = /*some value*/;
CPOSAgent::Instance().AddUserExperienceID(m_UserExperienceId, nCheckNum);
Was it helpful?

Solution

You're compiling that code with -fpermissive set which is downgrading the error to a warning.

 -fpermissive
  Downgrade some diagnostics about nonconformant code from errors to warnings.
  Thus, using -fpermissive will allow some nonconforming code to compile.

What does the fpermissive flag do?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top