0

When I compile my solution in Android (Tegra NDK Compiler) or Linux (g++), I get this warning on GRPPOINT operator overloading. However, I do not get it on Visual Studio (cl).

  ../../../Gen/Graphic/GRPPoint.h: In member function 'GRPPOINT& GRPPOINT::operator/(GLFLOAT)':
D:\Projects\Gen\Graphic\GRPPoint.h(86,22): warning : reference to local variable 'tmp' returned [-Wreturn-local-addr]
               GRPPOINT tmp;

The code is an operator overloading for the Class GRPPOINT:

GRPPOINT& operator / (GLFLOAT scalar)
{
GRPPOINT tmp;
tmp.x   =   this->x /scalar;
tmp.y   =   this->y /scalar;
tmp.z   =   this->z /scalar;
return tmp;
}

Seems that copying by reference of the object tmp is not allowed. I might be confusing the use of the &. The code works fine, and does what it should, but I dont know how to overcome this warning.

Thanks.

diego.martinez
  • 1,051
  • 2
  • 11
  • 25

0 Answers0