Sign in to follow this  
And3rs87

'type cast' : conversion from 'uintptr_t' to 'void *' of greater size

Recommended Posts

so, im trying to compile my graphic-engine but I get 2 warnings about the same thing. the warning directs me to near the bottom of this code.. _Val = (void *)(uintptr_t)_Ans; the warning i'm getting is warning C4312: 'type cast' : conversion from 'uintptr_t' to 'void *' of greater size And I have no clue about what goes wrong :P
_VIRTUAL _InIt do_get(_InIt _First, _InIt _Last,
		ios_base& _Iosbase, ios_base::iostate& _State,
			void *& _Val) const
		{	// get void pointer from [_First, _Last) into _Val
		char _Ac[_MAX_INT_DIG], *_Ep;
		errno = 0;

 #ifdef _LONGLONG
		int _Base = _Getifld(_Ac, _First, _Last, ios_base::hex,
			_Iosbase.getloc());	// gather field
		const _ULONGLONG _Ans =
			(sizeof (void *) == sizeof (unsigned long))
				? (_ULONGLONG)::strtoul(_Ac, &_Ep, _Base)
				: ::_STOULL(_Ac, &_Ep, _Base);

 #else /* _LONGLONG */
		const unsigned long _Ans = ::strtoul(_Ac, &_Ep,
			_Getifld(_Ac, _First, _Last, ios_base::hex,
				_Iosbase.getloc()));	// gather field, convert
 #endif /* _LONGLONG */

		if (_First == _Last)
			_State |= ios_base::eofbit;
		if (_Ep == _Ac || errno != 0)
			_State |= ios_base::failbit;
		else
			_Val = (void *)(uintptr_t)_Ans;	// deliver value
		return (_First);
		}

Share this post


Link to post
Share on other sites
Not directly an answer to your question, but why on earth does this function even exist? I don't entirely grok what it is doing, but it appears to be an attempt to subvert the processing of old-fashioned iostreams to provide handling of void * pointers? In that case, modern iostreams already do this internally.

Share this post


Link to post
Share on other sites
Quote:
Original post by swiftcoder
it appears to be an attempt to subvert the processing of old-fashioned iostreams to provide handling of void * pointers

This is lines 517 to 545 of the xlocnum header from MSVC 2003. In other words, part of the implementation of iostreams.

In any case, this a /Wp64 warning that can be safely ignored, especially given that it's living in the compiler's own headers. /Wp64 produces a lot more false positives than useful warnings. I generally suggest disabling the setting.

Share this post


Link to post
Share on other sites
Quote:
Original post by SiCrane
Quote:
Original post by swiftcoder
it appears to be an attempt to subvert the processing of old-fashioned iostreams to provide handling of void * pointers

This is lines 517 to 545 of the xlocnum header from MSVC 2003. In other words, part of the implementation of iostreams.

In any case, this a /Wp64 warning that can be safely ignored, especially given that it's living in the compiler's own headers. /Wp64 produces a lot more false positives than useful warnings. I generally suggest disabling the setting.


I have tried that, but when I disable the wp64 I get a memory failure.


"The instructions at "0x00340540" referenced memory at "0x001c00c". The memory could not be "read".

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this