Re: VariantChangeType - Conversion from VT_I8 to VT_BSTR is bugged
- From: kramerjames <kramerjames@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 18 Oct 2007 12:37:03 -0700
As a side note, I submitted the bug here
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=305270
I got a reply that they changed the Status to Resolved (External) with no
indication of their version of a workaround or that it is going to be fixed.
Is this typical? Cause if it is, I want to resolve all my bugs this way :)
"Brian Muth" wrote:
I can confirm it is bug. Indeed, I modified the code as shown below.
VARIANT vt;
HRESULT hr;
vt.vt = VT_I8;
vt.llVal = 0x8000000FFFFFFFFF;
At this point I indeed confirmed vt.llVal was filled with the above hex number, but
hr = VariantChangeType(&vt,&vt,0,VT_BSTR);
Yields a BSTR containing "-1"!
I suggest submitting this as a bug to http://connect.microsoft.com/
Brian
"kramerjames" <kramerjames@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:A8B75A83-6699-4ABE-8616-4FD9B8BDFFE5@xxxxxxxxxxxxxxxx
During my testing, it never truncated it, the assignment of the negative
number always showed llVal with the correct number. But as soon as I called
VariantChangeType it truncated it.
Just for curiousities sake, I made the change you advised. It still
produces the same behavior in either case.
"Alexander Nickolov" wrote:
Your constant is 32-bit - the compiler does the truncation for
you. You need to specify it as 64-bit:
vt.llVal = -123456789012LL;
or
vt.llVal = -123456789012i64;
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@xxxxxxxx
MVP VC FAQ: http://vcfaq.mvps.org
=====================================
"kramerjames" <kramerjames@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:15A54DD5-03F2-4B1C-92CF-5C9577005382@xxxxxxxxxxxxxxxx
I have created a simple test.
VARIANT vt;
HRESULT hr;
vt.vt = VT_I8;
vt.llVal = -123456789012;
hr = VariantChangeType(&vt,&vt,0,VT_BSTR);
debugging this yields vt to contain the string "-3197704724". This works
for all values except large negative values greater than 4 bytes.
oleauto32.dll version 5.1.2600.3139
ole32.dll version 5.1.2600.2726
Can anyone help me figure out how to overcome this problem?
- References:
- VariantChangeType - Conversion from VT_I8 to VT_BSTR is bugged
- From: kramerjames
- Re: VariantChangeType - Conversion from VT_I8 to VT_BSTR is bugged
- From: Alexander Nickolov
- Re: VariantChangeType - Conversion from VT_I8 to VT_BSTR is bugged
- From: Brian Muth
- VariantChangeType - Conversion from VT_I8 to VT_BSTR is bugged
- Prev by Date: Re: More COM objects created than I expected
- Next by Date: Re: More COM objects created than I expected
- Previous by thread: Re: VariantChangeType - Conversion from VT_I8 to VT_BSTR is bugged
- Next by thread: Re: VariantChangeType - Conversion from VT_I8 to VT_BSTR is bugged
- Index(es):
Relevant Pages
|