You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "Cynerd (via GitHub)" <gi...@apache.org> on 2026/03/02 13:25:22 UTC

[PR] libm: fix truncl when long double has same size as double [nuttx]

Cynerd opened a new pull request, #18480:
URL: https://github.com/apache/nuttx/pull/18480

   ## Summary
   
   The truncl implementation expects 80 bit little endian representation of the floating point number. That is valid for x86 but not for example arm. On arm long double is the same as double.
   
   This was discovered with newer version of GCC (15.2.0) that started emitting warning:
   
   ```
     libm/lib_truncl.c: In function 'truncl':
     libm/lib_truncl.c:68:14: error: 'u.i.se' is used uninitialized [-Werror=uninitialized]
        68 |   int e = u.i.se & 0x7fff;
           |           ~~~^~~
     libm/lib_truncl.c:63:17: note: 'u' declared here
        63 |   union ldshape u =
           |                 ^
     libm/lib_truncl.c:69:14: error: 'u.i.se' is used uninitialized [-Werror=uninitialized]
        69 |   int s = u.i.se >> 15;
           |           ~~~^~~
     libm/lib_truncl.c:63:17: note: 'u' declared here
        63 |   union ldshape u =
           |                 ^
     libm/lib_truncl.c:63:17: error: 'u.i.se' is used uninitialized [-Werror=uninitialized]
   ```
   
   ## Impact
   
   This is technically a fix for `truncl` on platforms that have `long double` of the same size as `double`, as the logic was correct only for 80 bit float.
   
   ## Testing
   
   The testing was performed only by compilation, as the implementation just redirects to the `trunc` instead. The warning disappeared with the changes made in this PR.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] libm: fix truncl when long double has same size as double [nuttx]

Posted by "Cynerd (via GitHub)" <gi...@apache.org>.
Cynerd commented on PR #18480:
URL: https://github.com/apache/nuttx/pull/18480#issuecomment-3984454517

   I just tested it with x86 and the condition is wrong because https://github.com/apache/nuttx/blob/master/include/nuttx/lib/float.h#L67 ... ups


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] libm: fix truncl when long double has same size as double [nuttx]

Posted by "Cynerd (via GitHub)" <gi...@apache.org>.
Cynerd closed pull request #18480: libm: fix truncl when long double has same size as double
URL: https://github.com/apache/nuttx/pull/18480


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] libm: fix truncl when long double has same size as double [nuttx]

Posted by "Cynerd (via GitHub)" <gi...@apache.org>.
Cynerd commented on PR #18480:
URL: https://github.com/apache/nuttx/pull/18480#issuecomment-4841990984

   Replaced by #19242


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org