This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug math/4775] New: tgmath macros don't work as expected in some situations


the following code fails:

#include <tgmath.h>                                                            
                                                                 
                                                                               
                                                                 
void vec_from_polar(float v[2], const float p[2]) {                            
                                                                 
        // error                                                               
                                                 
        // float phi = p[1]; ..cos(phi); <- solves it                          
                                                                 
        v[0] = p[0] * cos(p[1]);                                               
                                                                 
        v[1] = p[0] * sin(p[1]);                                               
                                                                 
}                                                                              
                                                                 
                                                                               
                                                                 
int main() {                                                                   
                                                                 
        float vec[2];                                                          
                                                                 
        const float polar[2] = {.3f, .4f};                                     
                                                                 
                                                                               
                                                                 
        vec_from_polar(vec, polar);                                            
                                                                 
                                                                               
                                                                 
        // works                                                               
                         
        vec[0] = polar[0] * cos(polar[1]);                                     
                                                                 
        vec[1] = polar[0] * sin(polar[1]);                                     
                                                                 
                                                                               
                                                                 
        return 0;                                                              
                                                                 
}                                                                              
                                                                 


a shorter version for testing:

#include <tgmath.h>
void f(const float x[1]) {exp(x[0]);}


compiler error messages:

cc    -c -o t.o t.c
t.c: In function ?f?:
t.c:2: error: assignment of read-only variable ?__tgmres?
t.c:2: error: assignment of read-only variable ?__tgmres?
t.c:2: error: assignment of read-only variable ?__tgmres?
t.c:2: error: assignment of read-only variable ?__tgmres?
t.c:2: error: assignment of read-only variable ?__tgmres?
t.c:2: error: assignment of read-only variable ?__tgmres?

-- 
           Summary: tgmath macros don't work as expected in some situations
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: math
        AssignedTo: aj at suse dot de
        ReportedBy: nszabolcs at gmail dot com
                CC: glibc-bugs at sources dot redhat dot com


http://sourceware.org/bugzilla/show_bug.cgi?id=4775

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]