From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) by sourceware.org (Postfix) with ESMTPS id 6028B3858D35 for ; Sun, 20 Sep 2020 09:40:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6028B3858D35 Received: by mail-io1-xd43.google.com with SMTP id z13so12200818iom.8 for ; Sun, 20 Sep 2020 02:40:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=ykYc34K38fMYKHYwwUBtEBG3eEYWJSk3AaiMjFDqS84=; b=dWEEC9eDO751XJVGQTaY7b3HVgB1dhRrfkCxYD22dVI+uj8Gxv/4apncysE1Drjovp qfUwND7PfyTuDQ4kgJYTIMgc2B5sQFG69A4KTa14obR//Uq5nA7xf9yOqSUI+uzr97yP yEsMF7cLwCpehCKjb0cS+GU8DXvIabm4Nac4aooVyQkgXXBfsInRowiyiSNy7gdBtLWm JONFf7sVm6uguOtUirq8xxok6rdDVDKCxrfa2O6k7p1sHdYP6dy+vIt56ul8UWO0o0ue fU34sWE4UwdCHSazIsIITGTMjxLAIqUKEouHJXMlYaXzBprQodlKZmvv5Hhr4UxhDTM2 zbcQ== X-Gm-Message-State: AOAM5333jYSzhh0PuvMRVj7Nh+E7bZbhKP4vUL9/HVwJy83tgmzGDOm1 1esY5qR2Xbuvp8tAZ8jwNExzgkMTv2cih7VREZ739YIaBJM= X-Google-Smtp-Source: ABdhPJxhVd57nuczRo/2ETUPgr9K7m8Zdjh4UlcapS4zc4Ebhfczsctl6lObnIdyYm29iro8yYY0Q380GawAV8Ay7eM= X-Received: by 2002:a6b:c8d6:: with SMTP id y205mr33362794iof.177.1600594847628; Sun, 20 Sep 2020 02:40:47 -0700 (PDT) MIME-Version: 1.0 From: Ruslan Kabatsayev Date: Sun, 20 Sep 2020 12:40:36 +0300 Message-ID: Subject: Newlib's complex.h is incompatible with GCC 9's tgmath.h To: newlib@sourceware.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Sep 2020 09:40:49 -0000 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 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