I have been using somewhat similar code to following many times in Embedded C.
#include <stdio.h>
int g_uArray[5] =
{ 1, 1, 2, 3, 5};
void* foo( int uIndex );
int main()
{
int* uVar;
uVar = foo( 2 );
printf( "Value = %u\n", *uVar );
return 0;
}
void* foo( int uIndex )
{
return (void*) &g_uArray[uIndex];
}
The above code works perfectly when compiled with gcc but it throws an error when compiled with g++
invalid conversion from ‘void*’ to ‘int*’
for line
uVar = foo( 2 );
However it can be compiled by giving -fpermissive flag. Now, my question is why it is so critical that C++ gives the error (gcc -Wall doesn't even give warning). If I compile using -fpermissive will it create some runtime problem?