0

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);
void.pointer
  • 24,859
  • 31
  • 132
  • 243
  • gcc warned you that you did something wrong, `-fpermissive` is the name of the option to enable-disable this warning. use `-Wall -Werror` and you'll be on the safe side – user3159253 May 05 '14 at 22:54
  • Also you may take a look at [this page](http://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html), if you need to perform "fine tuning" of warning/error settings right in the code. – user3159253 May 05 '14 at 22:57
  • What made you use `-fpermissive` in the first place? Know the tools you are using. Don't just cut and paste from someone else's makefile. That's cargo cult programming. It will get you in trouble. – David Hammen May 05 '14 at 23:38

1 Answers1

4

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?

Community
  • 1
  • 1
Marco A.
  • 43,032
  • 26
  • 132
  • 246