Topic
  • No replies
SystemAdmin
SystemAdmin
196 Posts

Pinned topic xlc problem with __real__ and __imag__

‏2010-04-16T21:28:35Z |
I am having problems with the XLC implementation of a GCC feature __real__ and __imag__. I am trying to get the real part of a complex number, which I refer to with a pointer. XLC (v9.0 for Linux) exits with an error, that "Operand must be a modifiable lvalue.". It is somewhat strange, since I am using the same operand as a modifiable lvalue a line earlier. With GCC everything is fine.

If somebody could shed a light on this issue, I would be grateful.

Here is the code snippet:

#include <complex.h>

int main()
{
    double complex a, *b;
    b= &a;

    /* OK */
    *b = 1.0 + 2.0*I;
    
    /* ERROR: 1506-025 (S) Operand must be a modifiable lvalue. */
    __real__ (*b) = 1.0;
    
    /* ERROR: 1506-025 (S) Operand must be a modifiable lvalue. */
    __imag__ (*b) = 2.0;
}
Updated on 2014-03-24T22:18:49Z at 2014-03-24T22:18:49Z by iron-man
  • SystemAdmin
    SystemAdmin
    196 Posts

    Re: xlc problem with __real__ and __imag__

    ‏2010-05-06T22:21:03Z  
    The error does not refer to the operand of __real__ or __imag__, but to the left operand of the assignment operator. In this case, the left operand should be considered a modifiable lvalue; however, it seems that the compiler does not like having the pointer dereference instead of the name of a complex variable.
  • SystemAdmin
    SystemAdmin
    196 Posts

    Re: xlc problem with __real__ and __imag__

    ‏2010-05-14T13:50:38Z  
    The error does not refer to the operand of __real__ or __imag__, but to the left operand of the assignment operator. In this case, the left operand should be considered a modifiable lvalue; however, it seems that the compiler does not like having the pointer dereference instead of the name of a complex variable.
    This seems to be C only issue. Your code should be accepted by C++.