lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I have one warning when compiling Lua 5.2.1 in VS 2010:

D:/............./Lua/modified/src/lgc.c(988): warning C4146: unary minus
operator applied to unsigned type, result still unsigned

MSDN article about warning: http://msdn.microsoft.com/en-us/library/4kh09110.aspx

It occurs in new code, not present in previous releases. 

Quick test with following application that also generates this warning shows
that VS 2010 still negates unsigned values (it prints -100) but we cannot knew
for sure what other compilers/platforms will do.

----------------------------------------------
#include <stdio.h>

int main ()
{
	typedef union Test
	{
		unsigned int	u;
		int	i;
	} Test_t;

	Test_t t1;

	t1.u = 100;
	t1.u = - t1.u;

	printf("Result: %d\n", t1.i );

	return 0;
}
----------------------------------------------