Last active
August 29, 2015 14:07
-
-
Save hi2p-perim/cb33048e8c0773e9bea8 to your computer and use it in GitHub Desktop.
Tricky compilation error with __assume. Checked with VS2013 (/W4 /WX options enabled)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
struct A | |
{ | |
int n; | |
A(int n) : n(n) {} | |
}; | |
A Func(int n) | |
{ | |
if (n < 2) | |
{ | |
return A(1); | |
} | |
else if (n >= 2) | |
{ | |
return A(2); | |
} | |
else | |
{ | |
#if 1 | |
// OK | |
//__assume(0); | |
return A(3); | |
#elif 1 | |
// OK | |
__assume(0); | |
//return A(3); | |
#else | |
// warning C4702, error C2220 | |
__assume(0); | |
return A(3); | |
#endif | |
} | |
} | |
int main() | |
{ | |
std::cout << Func(1).n << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment