Heapsort won't compile bug

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
roninmagus
Posts: 91
Joined: Fri Oct 31, 2003 5:03 am

Heapsort won't compile bug

Post by roninmagus »

I've come across a bug which can be duplicated very easily. I searched the forums but found nothing about it. This is a compile-time bug.

It happens in the file heapsort.h, and is very easy to correct.

This code will compile fine:

Code: Select all

#include <irrlicht.h>

int main()
{
	irr::core::array<int> myArray;

	myArray.push_back(6);
	myArray.push_back(1);
	myArray.push_back(9);

	myArray.sort();

	return 0;
}
However, this code will not, only difference is using namespace irr::core (won't compile in visual studio 6.0):

Code: Select all

#include <irrlicht.h>

using namespace irr::core;

int main()
{
	irr::core::array<int> myArray;

	myArray.push_back(6);
	myArray.push_back(1);
	myArray.push_back(9);

	myArray.sort();

	return 0;
}
It will not compile because there is a variable in heapsort.h's heapsort function which is named "array." When a source file (.cpp) uses the namespace irr::core, it also uses it for all included files... therefore the variable named "array" conflicts with the class named "array".

This could very easily be fixed, by simply changing the variable name in the heapsort function.

It's not a crippling bug, but it is annoying :D
daveandrews.org - A Christian Programmer's Weblog | Dusty Engine - A Task Engine for Irrlicht
roninmagus
Posts: 91
Joined: Fri Oct 31, 2003 5:03 am

Post by roninmagus »

I have tried compiling both on g++ with redhat fedora core 1, and both examples compile fine.

The one it broke on was a default install of VC++6. I think since it's all inlined in an h file, it only breaks in certain cases... in any case, changing the var name is a good idea I think :D
daveandrews.org - A Christian Programmer's Weblog | Dusty Engine - A Task Engine for Irrlicht
Post Reply