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 ;
*/