different result between debug and release : <p>When I use debug mode to build the code, the res is 0, correct.
But After I use release mode to build the code, the res is 1.
Even though I try to use the #pragma instruction to disable the compiler's optimalzation, the error is still existed.</p>

<p>here's the code:</p>

<pre><code>#include &lt;cstdio&gt;

#define ulong unsigned __int64

void hashTransfer(const char * src, unsigned char hash[])
{
    sscanf_s(src, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
        &amp;hash[0], &amp;hash[1], &amp;hash[2], &amp;hash[3], &amp;hash[4], &amp;hash[5], &amp;hash[6], &amp;hash[7],
        &amp;hash[8], &amp;hash[9], &amp;hash[10], &amp;hash[11], &amp;hash[12], &amp;hash[13], &amp;hash[14], &amp;hash[15],
        &amp;hash[16], &amp;hash[17], &amp;hash[18], &amp;hash[19], &amp;hash[20], &amp;hash[21], &amp;hash[22], &amp;hash[23],
        &amp;hash[24], &amp;hash[25], &amp;hash[26], &amp;hash[27], &amp;hash[28], &amp;hash[29], &amp;hash[30], &amp;hash[31]);
}
#pragma optimize("", off)
bool compartor(const unsigned char* lhs, const unsigned char* rhs)
{
    const ulong* lhsP = (const ulong *)lhs;
    const ulong* rhsP = (const ulong *)rhs;
    ulong lhs4 = *(lhsP + 3);
    ulong lhs3 = *(lhsP + 2);
    ulong lhs2 = *(lhsP + 1);
    ulong lhs1 = *(lhsP);
    ulong rhs4 = *(rhsP + 3);
    ulong rhs3 = *(rhsP + 2);
    ulong rhs2 = *(rhsP + 1);
    ulong rhs1 = *(rhsP);
    //int a = lhs1 &lt; rhs1;
    //int b = (lhs1 == rhs1 &amp;&amp; lhs2 &lt; rhs2);
    //int c = (lhs1 == rhs1 &amp;&amp; lhs2 == rhs2 &amp;&amp; lhs3 &lt; rhs3);
    //int d = (lhs1 == rhs1 &amp;&amp; lhs2 == rhs2 &amp;&amp; lhs3 == rhs3 &amp;&amp; lhs4 &lt; rhs4);
    //printf("\n%llx %llx\n", lhs1, rhs1);
    //printf("%llx %llx\n", lhs2, rhs2);
    //printf("%llx %llx\n", lhs3, rhs3);
    //printf("%llx %llx\n", lhs4, rhs4);
    return (lhs1 &lt; rhs1)
        || (lhs1 == rhs1 &amp;&amp; lhs2 &lt; rhs2)
        || (lhs1 == rhs1 &amp;&amp; lhs2 == rhs2 &amp;&amp; lhs3 &lt; rhs3)
        || (lhs1 == rhs1 &amp;&amp; lhs2 == rhs2 &amp;&amp; lhs3 == rhs3 &amp;&amp; lhs4 &lt; rhs4);
}
#pragma optimize("", on)

int main()
{
    unsigned char hash1[32];
    hashTransfer("ff3f4036a1164d1ddbad5b3edf9022fddb3e1961a54a922708a6c1ffc49e5489", hash1);
    unsigned char hash2[32];
    hashTransfer("ff3f4036a1164d1ddbad5b3edf9022addb3e1961a54a922708a6c1ffc49e5489", hash2);
    bool res = 0;
    res = compartor(hash1, hash2);
    printf("%d", res);
    getchar();
    return 0;
}
</code></pre>
