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

Started by
4 comments, last by And3rs87 14 years, 9 months ago
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);
		}
Advertisement
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.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

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.
Quote:Original post by SiCrane
This is lines 517 to 545 of the xlocnum header from MSVC 2003. In other words, part of the implementation of iostreams.
That makes a lot more sense - I had assumed it was in the OP's own code.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

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".
Fail at me, I ran the debug, and then I saw that I havnt installed openAL :D

feel kinda stupid now ^^

This topic is closed to new replies.

Advertisement