https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122879
Bug ID: 122879
Summary: bool from complex with SNAN not raise FE_INVALID
Product: gcc
Version: 15.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: tydeman at tybor dot com
Target Milestone: ---
This code fails:
#include <assert.h>
#include <errno.h>
#include <fenv.h>
#include <float.h>
#include <complex.h>
#include <math.h>
int main(void){
static long double complex ldc = CMPLXL( 1.L/3.L, LDBL_SNAN );
bool b;
int flags;
assert(!issignaling( creall( ldc ) ) );
assert( issignaling( cimagl( ldc ) ) );/* make sure is an SNAN */
errno = 0;
feclearexcept( FE_ALL_EXCEPT );
b = ldc; /* what we are testing */
flags = fetestexcept( FE_ALL_EXCEPT );
assert( true == b );
assert( 0 == errno );
assert( 0 != flags ); /* fails here */
assert( FE_INVALID == flags );
return 0;
}
Running on Intel Core i5 7th gen with Fedora Linux 42
gcc 15.2.1-4
# flags common to both compiler and linker
export CLFLAGS="\
-fsanitize=undefined \
-fsanitize=address \
-fsanitize=bounds-strict \
-fstack-protector-all"
# flags for compiler
export CFLAGS="-H -std=c23 -O0 -march=native -mhard-float -mfpmath=387
-mieee-fp \
-enable-decimal-float=yes \
-fexcess-precision=standard \
-ffp-contract=off \
-fmath-errno \
-fno-associative-math \
-fno-builtin \
-fno-cx-limited-range \
-fno-fast-math \
-fno-finite-math-only \
-fno-reciprocal-math \
-fno-unsafe-math-optimizations \
-frounding-math \
-fsignaling-nans \
-fsigned-zeros \
-ftrapping-math \
${INCS} \
-I/usr/include/dfp"