[PATCH] Small fix for tgmath.h

YunZhong Gao gaoyunzhong at gmail.com
Fri Mar 29 13:51:37 PDT 2013


gaoyunzhong added you to the CC list for the revision "Small fix for tgmath.h".

Hi,

This patch attempts to fix the return types of the complex creal functions. They should return non-complex types according to C99 section 7.22c6 and 7.3.9.5. The fix is to remove the extra _Complex keywords from the prototypes of the creal functions in a similar manner as Kristof Beyls did to fabs a few weeks ago.

I am not sure where I can add a regression test for a header change like this. With the small test case below, GCC 4.4.3 returns 4 at run-time while Clang trunk r176911 returns 8.

``` /* test.c */
#include <stdio.h>
#include <tgmath.h>

float f;

int main() {
  printf("%lu\n", sizeof(creal(f)));
  return 0;
}
/* end of file */```

Could someone review and commit the patch for me?

Thanks, Gao.

http://llvm-reviews.chandlerc.com/D595

Files:
  lib/Headers/tgmath.h

Index: lib/Headers/tgmath.h
===================================================================
--- lib/Headers/tgmath.h
+++ lib/Headers/tgmath.h
@@ -1340,15 +1340,15 @@
 
 // creal
 
-static float _Complex
+static float
     _TG_ATTRS
     __tg_creal(float __x) {return __x;}
 
-static double _Complex
+static double
     _TG_ATTRS
     __tg_creal(double __x) {return __x;}
 
-static long double _Complex
+static long double
     _TG_ATTRS
     __tg_creal(long double __x) {return __x;}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D595.1.patch
Type: text/x-patch
Size: 490 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130329/8fca3a35/attachment.bin>


More information about the cfe-commits mailing list