Salbris/Spider-Fish — Issue #33: Persistent reference of temporary variable in CollisionManager::GetCandidateList empty constructor may fail to compile.
Author: erisco
Created: 2011-10-11 17:58:03+00:00
State: open
Labels: Bug

Persistent reference of temporary variable in CollisionManager::GetCandidateList may fail to compile.

Offending code:

```c++
class GetCandidateList {
public:

// empty constructor
GetCandidateList() : _target(PhysicalEntity()) { }

// ... snipped ...

private:
PhysicalEntity &_target;
};
```

This happened to Jeff using clang, whereas in VS10 only a compiler warning is produced. GCC is untested.

In any case, the compilers are right to complain as it is an unsafe practice.

Possible alternatives:

* Use PhysicalEntity* throughout the collision system instead of references. This will require a lot of rewriting and testing.
* Create a PhysicalEntity member and use it for the reference. This increases the size of the object but is a quick and easy solution.