bugGNU Scientific Library - Bugs: bug #65912, GSL_SET_COMPLEX is wrong if...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #65912: GSL_SET_COMPLEX is wrong if complex.h has no support for imaginary numbers

Submitter:  Sergey B Kirpichev <skirpichev>
Submitted:  Sun 23 Jun 2024 06:27:29 PM UTC
   
 
Category:  None Severity:  3 - Normal
Operating System:  Status:  None
Assigned to:  None Open/Closed:  Open
Release: 

Sun 23 Jun 2024 06:27:29 PM UTC, original submission:  

Consider following code:
----->8----
/* a.c */
#include <complex.h>
#include <stdio.h>
#include <gsl/gsl_complex.h>
int main(void)
{
    gsl_complex z;
    GSL_SET_COMPLEX(&z, -0.0, 0.0);
    printf("(%lf%+lf)\n", GSL_REAL(z), GSL_IMAG(z));
    return 0;
}
--->8------

$ gcc a.c -std=c11 -lgsl && ./a.out  # expected (-0.000000+0.000000)
(0.000000+0.000000)

(GSL compiled by: CC="gcc -std=c11" ./configure -q && make -s)

Similar wrong results could be reproduced for other special components,
i.e. NAN's or INFINITY's.  Issue should be fixed by using macro CMPLX, available in C11+.

Patch attached.

Sergey B Kirpichev <skirpichev>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #56260:  0001-Correct-GSL_SET_COMPLEX-if-native-complex-available.patch added by skirpichev (1KiB - text/x-patch - complete patch with _Generic)
file #56195:  CMPLX.diff added by skirpichev (616B - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by skirpichev (Submitted the item)
  •  

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-07-11 skirpichev Attached File- Added 0001-Correct-GSL_SET_COMPLEX-if-native-complex-available.patch, #56260
    2024-06-23 skirpichev Attached File- Added CMPLX.diff, #56195

    Back to the top

    Powered by Savane 3.13-269c.
    Corresponding source code