Crash std::cout<<float number

Hi!

I have the next code, that give me a crash when I show a float number. This only happens in BoxObject class:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
void PhysicCube::Initialize()
{
    setVisible(true);
    phyobject = new BoxObject();
}

BoxObject::BoxObject()
{
    std::cout<<"show float!!!!"<<std::endl;
    float t = 34;
    std::cout<<t<<std::endl;
    std::cout<<"crash!!!!"<<std::endl;     //Crash here
    Initialize();
    sideLength = glm::vec3(1.0f);
}


Does anyone know what happens?
What compiler and version is this?
@ResidentBiscuit: ¿do you know a compiler that fails on that?
@OP: try to create a minimal setup that does reproduce your issue.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
void PhysicCube::Initialize() //I expect this to be a private function that's called from the constructor
{
    setVisible(true);
    phyobject = new BoxObject(); // weird
}

BoxObject::BoxObject()
{
    std::cout<<"show float!!!!"<<std::endl;
    float t = 34;
    std::cout<<t<<std::endl;
    std::cout<<"crash!!!!"<<std::endl; //consider using a debugger instead
    Initialize();
    sideLength = glm::vec3(1.0f);
}
The problem appear when I extends BoxObject from PhysicObject.
My compiler is GCC version 4.7.1, 32 bit.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#ifndef BOXOBJECT_H
#define BOXOBJECT_H

#include "PhysicObject.hpp"
#include "../glm/glm.hpp"
class BoxObject //: public PhysicObject
{
    public:
        BoxObject();
        BoxObject(glm::vec3, glm::vec3, glm::vec3);
        virtual ~BoxObject();

        glm::vec3 getSides(void);
        void setSides(glm::vec3);

        void setGeom(dGeomID);

    protected:
        void Initialize(void);
    private:
        glm::vec3 sideLength;
};


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef PHYSICOBJECT_H
#define PHYSICOBJECT_H
#include "Component.hpp"
#define dSINGLE
#define DENSITY 0.5
#include <ode/ode.h>
#include "../glm/glm.hpp"

class PhysicObject : public Component
{
    public:
        PhysicObject();
        virtual ~PhysicObject();

        virtual dMass getMass(void);
        //virtual void setMass(dMass);

        virtual glm::vec3 getPosition(void);
        virtual void setPosition(glm::vec3);

        virtual glm::vec3 getEulerRotation(void);
        virtual void setEulerRotation(glm::vec3);

        virtual glm::mat4 getRotation(void);
        virtual void setRotation(glm::mat4);

        virtual glm::vec3 getVelocity(void);
        virtual void setVelocity(glm::vec3);

        virtual dGeomID getGeom(void);
        virtual void setGeom(dGeomID);

        virtual void Update(void);
        virtual void Draw(void);

    protected:
        virtual void Initialize();
        virtual void Load();
        dMass mass;
        glm::vec3 linearVelocity;
        dBodyID body;
        dGeomID geom;
    private:

};
Uhmmm...I detect the problem. If I delete the variable dMass from PhysicObject class ( remove other related methods with this), it works. But I don´t know why crash it yet...
Topic archived. No new replies allowed.