Re: VariantChangeType - Conversion from VT_I8 to VT_BSTR is bugged

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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?





.



Relevant Pages

  • Re: ATL generates bad code for Firing events with [out] arguments
    ... This is not a bug, ... VT_PI4 is not a valid vartype for a VARIANT. ... "DavidB" wrote in message ... >> Microsoft MVP, MCSD ...
    (microsoft.public.win32.programmer.ole)
  • Re: WARNING - Groupshield 6 + Exchange 2003
    ... It appears NAI have been working hard to resolve this ... And the solution is another hotfix to resolve a AD lookup on "system" ... emails bug. ...
    (microsoft.public.exchange.admin)
  • Re: Custom Dictionary
    ... A corrupted custom dictionary on a "fresh install" is the OLD bug, ... Leopard and is more difficult to resolve. ... John McGhie, Microsoft MVP (Word, Mac Word), Consultant Technical Writer, ...
    (microsoft.public.mac.office.word)
  • Compiler Bug or what Im doing wrong?
    ... 'Read-Attribute is not handled right in variant records, ... the finalizers for the default variant part ("when Keine_Angabe ... small example w/o GUI which succeeds in reproducing the bug. ...
    (comp.lang.ada)
  • Re: improving the Python docs -- a wiki? copy PHPs model?
    ... it is a significant barrier. ... Neither are required to submit a doc bug report, which can then be used by ... A suggested sentence to replace an incorrect sentence may take longer to ... doc glitches, without knowing either Latex or diff, by submitting comments ...
    (comp.lang.python)