Last active
October 28, 2021 06:20
-
-
Save nobu/fd0340d64e16485cc00282e049fd1f88 to your computer and use it in GitHub Desktop.
Sample code for https://developercommunity.visualstudio.com/t/With-__assume-isnan-after-isinf/1515649
This file contains 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
/* compile with -O2 */ | |
#include <math.h> | |
#include <float.h> | |
#define value_finite(d) 'f' | |
#define value_infinity() 'i' | |
#define value_nan() 'n' | |
static int | |
check_value(double value) | |
{ | |
if (isinf(value)) { | |
return value_infinity(); | |
} | |
else if (isnan(value)) { | |
return value_nan(); | |
} | |
__assume(1); // This causes the bug. | |
return value_finite(value); | |
} | |
int | |
main(void) | |
{ | |
int c = check_value(nan("")); | |
printf("NaN=>%c\n", c); | |
return c != value_nan(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment