Skip to content

Instantly share code, notes, and snippets.

@nobu
Last active October 28, 2021 06:20
Show Gist options
  • Save nobu/fd0340d64e16485cc00282e049fd1f88 to your computer and use it in GitHub Desktop.
Save nobu/fd0340d64e16485cc00282e049fd1f88 to your computer and use it in GitHub Desktop.
/* 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