Topic
5 replies Latest Post - ‏2012-09-25T19:28:20Z by LautaroFernandez
LautaroFernandez
LautaroFernandez
4 Posts
ACCEPTED ANSWER

Pinned topic Assigning variable with value obtained from a library value

‏2012-09-25T17:59:53Z |
Howdy,
I'm facing some trouble with a simple testcase of a program.
The idea is that a main process (binario.cpp) assigns the value of a foreign object's instance variable, defined by a library (libreria.h), in a global variable of that process.

We have been using this mechanism for a long time in our application and for our surprise, after upgrading xlc V7 to xlcV11, the default behaviour has changed.

I have made a small test program, which shows that a simple instruction such as assigning a variable in binario.cpp does not takes the expected value.
In this scenario, the l-value is the global variable COD and the r-value is the de value of the class variable CObjeto::COD.

Our AIX version is 7.1 and our compiler version is xlc V11 (IBM XL C/C++ for AIX, V11.1 (5724-X13)).

Thanks and kind regards!

Library's header (libreria.h)

#include <libreria.h> 

const std::string CObjeto::COD = 
"001";


Library's body(libreria.cpp)

#include <string> using namespace std; 

class CObjeto 
{ 

public: 

static 

const std::string COD; 
};


Main/Binary Process which calls the library (binario.cpp)

#include <iostream> #include <libreria.h> using namespace std; 

const string COD = CObjeto::COD;   

int main () 
{ cout << 
"CObjeto::COD [" <<  CObjeto::COD << 
"]" << endl; cout << 
"COD [" <<  COD << 
"]" << endl; 

return 0; 
}


Compiling rules

/usr/vacpp/bin/xlC -g -c -I./  libreria.cpp -o libreria.o /usr/vacpp/bin/xlC -G -o liblibreria.so libreria.o -lc -bdynamic -brtl /usr/vacpp/bin/xlC -g -c binario.cpp -o binario.o -I./  /usr/vacpp/bin/xlC -o binario -brtl binario.o -L. -llibreria ./binario


Actual console output

$ ./binario CObjeto::COD [001] COD [] $


EXPECTED console output

$ ./binario CObjeto::COD [001] COD [001] $
Updated on 2012-09-25T19:28:20Z at 2012-09-25T19:28:20Z by LautaroFernandez
  • LautaroFernandez
    LautaroFernandez
    4 Posts
    ACCEPTED ANSWER

    Re: Assigning variable with value obtained from a library value

    ‏2012-09-25T18:04:25Z  in response to LautaroFernandez
    (I'm sorry, I forgot to post the actual question)

    ¿Do you know any limitations in xlC v11 about accessing remote values, while assigning a global variable?
    I believe this is a bug in the xlc, or the xlC's installation.

    Thanks.
    • SystemAdmin
      SystemAdmin
      10114 Posts
      ACCEPTED ANSWER

      Re: Assigning variable with value obtained from a library value

      ‏2012-09-25T18:16:34Z  in response to LautaroFernandez
      not sure what changed, but you might have better luck asking at the xl cafe:

      http://www.ibm.com/software/rational/cafe/community/ccpp/

      .bri.
      • LautaroFernandez
        LautaroFernandez
        4 Posts
        ACCEPTED ANSWER

        Re: Assigning variable with value obtained from a library value

        ‏2012-09-25T18:50:17Z  in response to SystemAdmin
        Thanks brianh,
        Do you know if there is a way to move this thread to the other forum? (http://www.ibm.com/developerworks/forums/forum.jspa?forumID=2277 )

        I would not like to do crossposting.
        • SystemAdmin
          SystemAdmin
          10114 Posts
          ACCEPTED ANSWER

          Re: Assigning variable with value obtained from a library value

          ‏2012-09-25T18:52:53Z  in response to LautaroFernandez
          not that i know of. i think that you're OK to cross post - not a lot of traffic here on the CBEA forum.
          • LautaroFernandez
            LautaroFernandez
            4 Posts
            ACCEPTED ANSWER

            Re: Assigning variable with value obtained from a library value

            ‏2012-09-25T19:28:20Z  in response to SystemAdmin
            Thanks again briahh, I'll keep both of them up to date.
            (https://www.ibm.com/developerworks/forums/thread.jspa?threadID=456631)