Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect return values for pow(-1,nan) and tgamma(-inf) (IDFGH-5559) #7282

Closed
dpgeorge opened this issue Jul 18, 2021 · 5 comments
Closed
Assignees
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally

Comments

@dpgeorge
Copy link

Environment

  • Module or chip used: ESP32-PICO-D4 and ESP32C3
  • IDF version: v4.4-dev-2128-gf45b60b28
  • Build System: idf.py
  • Compiler version: xtensa-esp32-elf-gcc (crosstool-NG esp-2021r1) 8.4.0
  • Operating System: Linux

Problem Description

The return value of pow(-1, NAN) and tgamma(-INFINITY) are incorrect (according to standard C function semantics).

Expected Behavior

Actual Behavior

  • pow(-1, NAN) returns -1.000
  • tgamma(-INFINITY) returns INFINITY

Steps to reproduce / code

Create a simple program (eg based on hello_world) and add these lines:

    printf("pow(-1, nan) = %f\n", pow(-1, NAN));
    printf("tgamma(-inf) = %f\n", tgamma(-INFINITY));

Then compile, flash, run, and inspect output.

@espressif-bot espressif-bot added the Status: Opened Issue is new label Jul 18, 2021
@github-actions github-actions bot changed the title Incorrect return values for pow(-1,nan) and tgamma(-inf) Incorrect return values for pow(-1,nan) and tgamma(-inf) (IDFGH-5559) Jul 18, 2021
@0xjakob 0xjakob self-assigned this Nov 1, 2021
@espressif-bot espressif-bot added Status: In Progress Work is in progress and removed Status: Opened Issue is new labels Nov 1, 2021
@0xjakob
Copy link
Contributor

0xjakob commented Nov 15, 2021

@dpgeorge I think I found the issue with the pow() function. It seems to be a toolchain bug in newlib which has been fixed in newer versions than the one IDF uses. I'll check tgamma() as well. We'll probably provide a quick fix for IDF versions and/or include the fix in the newer IDF toolchain releases.

@0xjakob
Copy link
Contributor

0xjakob commented Nov 16, 2021

@zikalino
Copy link
Contributor

@dpgeorge we should have a fix for this issue very soon, as we will be upgrading toolchains to 2022r1.

@espressif-bot espressif-bot added Status: Opened Issue is new and removed Status: In Progress Work is in progress labels Mar 9, 2022
@espressif-bot espressif-bot added Status: In Progress Work is in progress and removed Status: Opened Issue is new labels Mar 22, 2022
antmak added a commit to antmak/dev-idf that referenced this issue Apr 14, 2022
@0xjakob
Copy link
Contributor

0xjakob commented Nov 14, 2022

@dpgeorge Note that the fix for tgamma() is only available on v5.0 (will be released soon). The other versions are stuck with an older toolchain version which brings an older newlib version that can't easily be fixed. In contrast, pow() has been fixed on v4.4 as well.

@dpgeorge
Copy link
Author

OK, thanks for fixing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally
Projects
None yet
Development

No branches or pull requests

4 participants