NVIDIA / MinkowskiEngine

Minkowski Engine is an auto-diff neural network library for high-dimensional sparse tensors
https://nvidia.github.io/MinkowskiEngine
Other
2.43k stars 360 forks source link

MinkowskiEngine/src/coordinate_map_manager.cpp(717): warning: returning reference to local temporary #455

Open midjji opened 2 years ago

midjji commented 2 years ago

You are returning an invalid reference which if queried may e.g. segfault when tested to see if its actually the case it is.

The problem is: auto& member_function(...) { ... if (in_map.size() == 0 || out_map.size() == 0) return detail::empty_map_functor<coordinate_type, TemplatedAllocator, CoordinateMapType, kernel_map_type>()();

...} This is a straight up programming error.

The simplest solution is to store an empty answer as a member and return a VALID reference to it instead. Want me to submit a merge?


To Reproduce git clone git@github.com:NVIDIA/MinkowskiEngine.git cd MinkowskiEngine python setup.py install


Expected behavior Do not return reference to local temporary.