Code Monkey home page Code Monkey logo

lightmaputil's People

Contributors

getchoo avatar hurricanepootis avatar jarateking avatar treacherousfiend avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

jarateking

lightmaputil's Issues

warning: reference to local variable ‘rhs’ returned

Using gcc 13.2.1

[ 50%] Building CXX object CMakeFiles/lightmaputil.dir/src/LightmapUtil.cpp.o
In file included from /home/micwoj92/LightmapUtil/src/LightmapUtil.h:4,
                 from /home/micwoj92/LightmapUtil/src/LightmapUtil.cpp:10:
/home/micwoj92/LightmapUtil/src/bsplib.h: In member function ‘dvertex_t& dvertex_t::operator+(dvertex_t)’:
/home/micwoj92/LightmapUtil/src/bsplib.h:367:24: warning: reference to local variable ‘rhs’ returned [-Wreturn-local-addr]
  367 |                 return rhs;
      |                        ^~~
/home/micwoj92/LightmapUtil/src/bsplib.h:362:40: note: declared here
  362 |         dvertex_t& operator+(dvertex_t rhs)
      |                              ~~~~~~~~~~^~~
/home/micwoj92/LightmapUtil/src/bsplib.h: In member function ‘dvertex_t& dvertex_t::operator-(dvertex_t)’:
/home/micwoj92/LightmapUtil/src/bsplib.h:374:24: warning: reference to local variable ‘rhs’ returned [-Wreturn-local-addr]
  374 |                 return rhs;
      |                        ^~~
/home/micwoj92/LightmapUtil/src/bsplib.h:369:40: note: declared here
  369 |         dvertex_t& operator-(dvertex_t rhs)
      |                              ~~~~~~~~~~^~~

Using clang 16.0.6 this code also generates warning:

[ 50%] Building CXX object CMakeFiles/lightmaputil.dir/src/LightmapUtil.cpp.o
In file included from /home/micwoj92/LightmapUtil/src/LightmapUtil.cpp:10:
In file included from /home/micwoj92/LightmapUtil/src/LightmapUtil.h:4:
/home/micwoj92/LightmapUtil/src/bsplib.h:367:10: warning: reference to stack memory associated with parameter 'rhs' returned [-Wreturn-stack-address]
                return rhs;
                       ^~~
/home/micwoj92/LightmapUtil/src/bsplib.h:374:10: warning: reference to stack memory associated with parameter 'rhs' returned [-Wreturn-stack-address]
                return rhs;
                       ^~~
2 warnings generated.

Program fails to build on MSVC

Forgot to actually make an issue post for this.

For some reason MSVC has a problem with us overloading a binary operator and as such fails to build.
in specific it hates this one and gives the error "binary '+': no operator found which takes a left-hand operand of type 'dvertex_t' (or there is no acceptable conversion)", even though our overloaded operator only accepts dvertex_t in both the left and right slots.

dvertex_t operator+(dvertex_t lhs, dvertex_t rhs)
{
	return lhs += rhs;
}

It probably would hate the other operators too but this is the first one it sees so it is the one that errors.
#14 attempted to fix this, but it unfortunately still errors out, although it complains about += instead of +. Oddly, with that error it seems to complain inside our + operator instead of when the + operator is called.

This builds and works correctly on other compilers like Clang, and even VS's intellisense seems to understand it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.