Home Dashboard Directory Help
Search

VS2008 C++ x64: buggy result in expression containing double and unsigned int64 by BenKaufmann1


Status: 

Active


1
0
Sign in
to vote
Type: Bug
ID: 526921
Opened: 1/25/2010 7:30:50 AM
Access Restriction: Public
0
Workaround(s)
view
0
User(s) can reproduce this bug

Description

#include <stdio.h>

typedef unsigned __int64 size_type;
typedef unsigned int uint32;

struct Foo {
    Foo() : strategy_(B), invert_(false) {}
    enum { A, B };
    int strategy_;
    bool invert_;
    bool test(uint32 a) {
        bool conflict = isTrue(a);
        if (strategy_ == A) {
            invert_ = conflict || strategy_ == B;
        }
        else if (conflict) {
            size_type capacity = 0;
            size_type minCap = 1;
            if (capacity > minCap) return true;
            minCap = minCap < 4 ? 4 : minCap;
            size_type cap = static_cast<size_type>(capacity * 1.5);
            if (cap > minCap) minCap = cap;
            CHECK_EQUAL(minCap, 4);
            return false;
        }
        return !conflict;
    }
    void CHECK_EQUAL(size_type n, size_type x) {
        if (n != x) throw n;
    }
    bool isTrue(uint32 x) {
        int bla;
        sscanf("1", "%d", &bla);
        return bla;
    }
};
int main() {
    Foo f;
    try {
        f.test(10864);
        printf("OK\n");
    }
    catch (size_type n) {
        printf("ERROR: n == %llu but should be 4!\n", n);
    }
}

Note: The first part of the generated code for the else if (conflict) branch is:

pxor        xmm0,xmm0
cvtsi2sd    xmm0,rdx
addsd     xmm0,mmword ptr [__real@43f0000000000000 (13FA42220h)]
mulsd     xmm0,mmword ptr [__real@3ff8000000000000 (13FA42218h)]
[...]

I think, there is a test/jns missing, i.e. the __real@43f0000000000000 should not be added
unconditionally.
Details
Sign in to post a comment.
Posted by Microsoft on 7/12/2010 at 12:10 PM
This issue will be fixed in the next release of Visual Studio.

Thanks again for reporting it.
Posted by Microsoft on 1/26/2010 at 11:55 PM
Thank you for reporting the issue.
We were able to reproduce the issue you are seeing. We are routing this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Microsoft on 1/26/2010 at 7:11 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.