This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/67840] New: #define function error


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

            Bug ID: 67840
           Summary: #define function error
           Product: gcc
           Version: 4.8.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ka_bena at yahoo dot fr
  Target Milestone: ---

/* #define function error */

#include <stdio.h>
#include <math.h>
#include <quadmath.h>

#define tadjib(x) (sizeof( x )== sizeof( float )       ?cosf(x) \
                  :sizeof( x )== sizeof( double )      ?cos(x)  \
                  :sizeof( x ) == sizeof( long double )?cosl(x) \
                  :cosq(x))

 int main(void)
{ 
   float       x = tadjib(1.F) ;
   double      y = tadjib(1. ) ;
   long double z = tadjib(1.L) ;

   printf("%E  \n" , x ) ;
   printf("%E  \n" , y ) ;
   printf("%LE \n" , z ) ;

   printf("\n");

   float       x1 = 1.F ;
   double      y1 = 1.  ;
   long double z1 = 1.L ;

   printf ( "%E  \n" , tadjib(x1) ) ;
   printf ( "%E  \n" , tadjib(y1) ) ;
   printf ( "%LE \n" , tadjib(z1) ) ;

   return 0 ;
}
/*
main_test_generic.c: In function âmainâ:
main_test_generic.c:29:4: warning: format â%Eâ expects argument of type
âdoubleâ, but argument 2 has type â__float128â [-Wformat=]
    printf ( "%E  \n" , tadjib(x1) ) ;
    ^
main_test_generic.c:30:4: warning: format â%Eâ expects argument of type
âdoubleâ, but argument 2 has type â__float128â [-Wformat=]
    printf ( "%E  \n" , tadjib(y1) ) ;
    ^
main_test_generic.c:31:4: warning: format â%LEâ expects argument of type âlong
doubleâ, but argument 2 has type â__float128â [-Wformat=]
    printf ( "%LE \n" , tadjib(z1) ) ;
    ^

Done.*/

/* Results:: 
   main_test_generic.exe

   5.403023E-01  
   5.403023E-01  
   5.403023E-01 

   -5.610234E-259  
   5.403023E-01  
   5.403023E-01 

   gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04)
   gcc -std=gnu99 -omain_test_generic.exe main_test_generic.c -lm  -lquadmath ;
*/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]