public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* Newlib's complex.h is incompatible with GCC 9's tgmath.h
@ 2020-09-20  9:40 Ruslan Kabatsayev
  0 siblings, 0 replies; only message in thread
From: Ruslan Kabatsayev @ 2020-09-20  9:40 UTC (permalink / raw)
  To: newlib

Hi all,

I was trying to compile a C file that uses the cos macro from
tgmath.h, and on Ubuntu 18.04 (gcc 6.3.1 arm-none-eabi, newlib 2.4.0)
it worked fine. But when trying to do the same compilation on Ubuntu
20.04 (gcc 9.2.1 arm-none-eabi, newlib 3.3.0), I get some errors.

I've reduced the test file to the following code:
```
#include <tgmath.h>

void test()
{
    double x=cos(4.5);
}
```
The errors from GCC are as follows:
```
In file included from test.c:1:
test.c: In function 'test':
test.c:5:14: error: 'ccosl' undeclared (first use in this function);
did you mean 'ccosh'?
    5 |     double x=cos(4.5);
      |              ^~~
test.c:5:14: note: each undeclared identifier is reported only once
for each function it appears in
test.c:5:14: error: argument 6 of '__builtin_tgmath' is not a function pointer
```

The difference between GCC 6 and GCC 9 is in the way the macros in
tgmath.h are defined. In GCC 6 they are in terms of
__builtin_choose_expr / __builtin_classify_type /
__builtin_types_compatible_p, which don't evaluate inactive
alternatives. And in GCC 9 they are defined via __builtin_tgmath,
which requires all alternatives to be valid function pointers.

So the current complex.h header from Newlib appears incompatible with
GCC 9's tgmath.h. A fix, I suppose, is at least to declare the missing
functions like ccosl. The best way would of course be to provide them
in full.

Regards,
Ruslan

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-09-20  9:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-20  9:40 Newlib's complex.h is incompatible with GCC 9's tgmath.h Ruslan Kabatsayev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).