https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121809

            Bug ID: 121809
           Summary: cast is ignored
           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 fails:
#include <assert.h>
#include <limits.h>
#include <errno.h>
#include <stdio.h>
#include <float.h>
#include <fenv.h>
#include <math.h>

int main(void){

  if(1){
    #define MAC (float)(FLT_MAX*FLT_MAX)        /* infinity */
    #define mynan(x) ((x) != (x))
    if( mynan( NAN ) ){
      assert( 1 && "true1 path is good" );      /* ok here */
    }else{
      assert( 0 && "false1 path is bad" );
    }
    if( mynan( MAC - MAC  ) ){
      assert( 1 && "true2 path is good" );
    }else{
      assert( 0 && "false2 path is bad" );      /* fails here */  
    }
  }
  return 0;
}

It appears that the cast to (float) is ignored (so MAC is not INFINITY)
or the MAC - MAC is "optimized" to 0 (instead of being a NAN).

Reply via email to