Dynamic arrays with static initialization and maybe a bug with sizeof

Xavier Bigand via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Dec 13 13:27:57 PST 2016


Hi,

I have the following code snippet :
	void	set()
	{
		GLfloat[]	data = [
			-1.0f, -1.0f, 0.0f,
			1.0f, -1.0f, 0.0f,
			0.0f,  1.0f, 0.0f,
		];

		glBindVertexArray(mVAO);
		glBufferData(GL_ARRAY_BUFFER, data.sizeof, cast(void*)data, 
GL_STATIC_DRAW);
	}


And I ask my self about the memory management of data, as my data array 
is statically initialized is it allocated on stack?

On another side I have a strange behavior with the sizeof that returns 8 
and not 36 (9 * 4) as I am expecting.


More information about the Digitalmars-d-learn mailing list