Skip to content

Incorrect return value from math.h tgammaf(-inf) (IDFGH-13360) #14273

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

Closed
3 tasks done
projectgus opened this issue Jul 30, 2024 · 3 comments
Closed
3 tasks done

Incorrect return value from math.h tgammaf(-inf) (IDFGH-13360) #14273

projectgus opened this issue Jul 30, 2024 · 3 comments
Assignees
Labels
Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Type: Bug bugs in IDF

Comments

@projectgus
Copy link
Contributor

projectgus commented Jul 30, 2024

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

v5.4-dev-1832-g23e4823f17, v5.0.4 and v5.2.2

Espressif SoC revision.

ESP32 and ESP32-C3

Operating System used.

Linux

How did you build your project?

Command line with idf.py

If you are using Windows, please specify command line type.

None

Development Kit.

ESP32-DevKitC, others

Power Supply used.

USB

What is the expected behavior?

Expect the result of tgammaf(-inf) to be NAN. (See https://pubs.opengroup.org/onlinepubs/9799919799/functions/tgammal.html and the C standard.)

This is a very similar issue to #7282 but applies to the single precision tgammaf() function.

What is the actual behavior?

Result of tgammaf(-inf) is inf

Steps to reproduce.

  1. Add these two lines to a program such as the hello_world example:
printf("tgamma(-inf) = %f\n", tgamma(-INFINITY));
printf("tgammaf(-inf) = %f\n", tgammaf(-INFINITY));

Note the first line is the double-precision function that was fixed in #7282, second line is single-precision function.

  1. Flash and execute.

Debug Logs.

tgamma(-inf) = nan
tgammaf(-inf) = inf

More Information.

Thanks for your time and attention. 😁

@projectgus projectgus added the Type: Bug bugs in IDF label Jul 30, 2024
@github-actions github-actions bot changed the title Incorrect return value from math.h tgammaf(-inf) Incorrect return value from math.h tgammaf(-inf) (IDFGH-13360) Jul 30, 2024
@espressif-bot espressif-bot added the Status: Opened Issue is new label Jul 30, 2024
@igrr
Copy link
Member

igrr commented Jul 30, 2024

Hi @projectgus!
This has been reported in upstream last year (https://sourceware.org/pipermail/newlib/2023/020171.html), but no fix there so far. We'll see if we can come up with a fix for this.

@gerekon
Copy link
Collaborator

gerekon commented Jul 31, 2024

Hi @projectgus!
We will try to fix this in the next toolchain release.

@projectgus
Copy link
Contributor Author

Thanks Ivan and Alexey. It's not particularly urgent from MicroPython perspective as we have a workaround, but I figured good to pass it upstream (so you can decide if you want to pass it to your upstream!)

@espressif-bot espressif-bot assigned Lapshin and unassigned gerekon Aug 15, 2024
@espressif-bot espressif-bot added Status: In Progress Work is in progress and removed Status: Opened Issue is new labels Aug 15, 2024
@espressif-bot espressif-bot added Status: Done Issue is done internally Resolution: NA Issue resolution is unavailable and removed Status: In Progress Work is in progress labels Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Type: Bug bugs in IDF
Projects
None yet
Development

No branches or pull requests

7 participants