Rybadour / Spider-Fish

A simple Bullet Hell Shooter.
socr.uwindsor.ca/~giga
8 stars 4 forks source link

Persistent reference of temporary variable in CollisionManager::GetCandidateList empty constructor may fail to compile. #33

Closed erisco closed 13 years ago

erisco commented 13 years ago

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

Offending code:

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:

erisco commented 13 years ago

Empty constructor was actually not needed, so it was removed in e0ab860